In
this article I am going to explain how to get WEEK DAY NAME between two date ranges
in sql server.
In
the previous article I have explained SQL SERVER Query to get first and lastdate with week day name of month, SQL SERVER Query to get week day name and Sqlserver: Get week day name and month name of current date.
Implementation:
Run
the below given query to get the week day name :-
declare @StartDate date
declare @Enddate date
set @StartDate = '20160701'
set @Enddate ='20160708'
;with dates as(
select
@StartDate as sdt
union
all
select
DATEADD(d,1,sdt) from dates where sdt<@Enddate
)
select ROW_NUMBER() OVER (ORDER BY sdt) AS [serial number],
sdt as [Date], datename(dw,sdt)as [Week Day Name] from
dates
OUTPUT:
0 Comments