How To Get The Week Number Of Year In SQL Server?

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


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
Get The Week Number Of Year


Related Articles & Tools

Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.