Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    61

    Unanswered: Start Date of the Current week

    Can anyone explain the result of the sql statement

    Select DATEADD(wk, DATEDIFF(wk, 6,getdate()), 6)


    Can we use this to get the start date of the current week always???

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    try this and see what it does --
    Code:
    Select DATEADD(wk, DATEDIFF(wk, 937,getdate()), 937)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2004
    Posts
    50
    Quote Originally Posted by forXLDB
    Can anyone explain the result of the sql statement

    Select DATEADD(wk, DATEDIFF(wk, 6,getdate()), 6)


    Can we use this to get the start date of the current week always???

    I always use days and devide by 7. I don't like the app's implementation of the datediff function. If you were to take today (2/18/2006) and calculate the number of weeks until tomorrw (2/19/2006), the answer would be 1 (if sun. begins the week). Sometimes it feels like a week between sat. and sun., but it aint 7 days.

    Anyway, dateadd retuns a date. I would use days in your datediff fn

    hth
    Monk
    The person who confesses ignorance shows it once; the person who conceals it shows it many times.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •