SQLTeam.com | Weblogs | Forums

Calculate week number of the month


#1

How to calculate exact week number of that particular month in sql server.
Suppose I have my date as 05/09/2015 as dd/mm/yyyy format then it should answer 1 if I have date as 06/09/2015 it should answer 2
Note: We consider Sunday as a first day of week


#2
week_no = datepart(week, [date]) 
        - datepart(week, dateadd(month, datediff(month, 0, [date]), 0)) + 1

#3

Thaks Khtan... :smile: