Home >Database >Mysql Tutorial >How to Calculate the Week Number of a Month in a SQL Server Calendar Table?
Calculating Week Number of Month for a Calendar Table
In order to determine the week number of a given month for your calendar table, spanning from 2000 to 2012, utilize the following query:
update TCalendar set WeekNumberOfMonth = DATEDIFF(week, DATEADD(MONTH, DATEDIFF(MONTH, 0, FullDateAlternateKey), 0), FullDateAlternateKey) +1
This query accomplishes the task by:
The above is the detailed content of How to Calculate the Week Number of a Month in a SQL Server Calendar Table?. For more information, please follow other related articles on the PHP Chinese website!