In
this article I am going to explain how to get the week number from current and specific
date in sql server.
In
the previous article I have explained Sql query to get WEEK DAY NAME betweentwo date ranges, SQL SERVER Query to get first and last date with week day nameof month and SQL SERVER Query to get week day name.
Implementation:
Sql server
query to get Current week number:
select [Current Week Number]=
datepart(dw, getdate())
Sql server
query to get week number of specific date:
declare @date datetime
= '2016-01-25'
select [Week Number is] =
datediff(week, dateadd(week, datediff(week, 0, dateadd(month, datediff(month, 0, @date), 0)), 0),
@date - 1) + 1
OUTPUT:
0 Comments