Sql query to get WEEK DAY NAME between two date ranges

In this article I am going to explain how to get WEEK DAY NAME between two date ranges in sql server.


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:
Sql query to get WEEK DAY NAME between two date ranges

Post a Comment

0 Comments