SQL QUERY For : Fetch the number of Weekends in the current month

;WITH CTE AS
(
select DATEFROMPARTS(YEAR(GETDATE()),MONTH(GETDATE()),1) as DtName
union all
select DATEADD(DAY,1,DtName) from CTE where DATEADD(Day,1,DtName) < DATEADD(DAY,1,EOMONTH(GETDATE()))
)select *,FORMAT(DtName,'dddd') as DayName from CTE where FORMAT(DtName,'ddd') in ('sat','sun')

Comments

Popular posts from this blog

Uploading Image to Sql Server Image Datatype in asp.net using fileupload Control

Get Running Sum of Query SQL Query