Results 1 to 2 of 2

Thread: How to get the cummulative week number and starting day of the week.

  1. #1
    Join Date
    Oct 2009
    Posts
    1

    How to get the cummulative week number and starting day of the week.

    Hi,
    I am struggling to get the week number and week day of the particular day. I know we can use Datepart function which is available in sql server 2008 to display the week number of the given date. but my situation is different. for example
    Datepart(wk,'2009-12-30') gives 53 weeks
    Datepart(wk,'2010-01-02') gives 1. but I wanted to display it as 54. How to generated it dynamically. Pls find the attached file along with this for more information. BugDate is the input and week number and starting of the week day are the expected outputs.... Can any one help me to solve this problem..

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2009
    Posts
    86
    chakrin, Try DATEDIFF of week with a starting date of '2007-12-22':

    DATEDIFF(wk,'2007-12-22','2009-12-28')

    This returns 106.

    I think 2007-12-22 is the correct staring date, but you may have to tweak it to ensure all days in the week return the same week value.

Posting Permissions

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