For today’s SQL Tip, we will see how to get the week number of the year. To get the week number for a specific date or the current date, we can use the DATEPART function. Here is the syntax and an example of using DATEPART to get the the week number
Syntax
DATEPART(week, <date>)
Where the first parameter can be either week or wk or ww. The second parameter should be a date datatype.
Example To Get Week Number
SELECT DATEPART(week, GetDate()) As 'Week Number',
DATEPART(wk, GetDate()) As 'Week Number',
DATEPART(ww, GetDate()) As 'Week Number'
/* Result */
Week Number Week Number Week Number
24 24 24
SELECT DATEPART(week, '2019/11/25') As 'Week Number'
/* Result */
Week Number
48
Reference
- About DATEPART at Microsoft Docs.
GREAT ..!! It helped getting the results.Thanks