SQLTeam.com | Weblogs | Forums

Calculate week number of the month


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

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


Thaks Khtan... :smile: