In this post I will explain, How to get Date list of Particular Month.
DECLARE @Date DATE='03/15/2016'
DECLARE @startDate DATE=CAST(MONTH(@Date) AS VARCHAR) + '/' + '01/' + + CAST(YEAR(@Date) AS VARCHAR)
DECLARE @endDate DATE=DATEADD(DAY,-1,DATEADD(MONTH,1,@startDate))
SELECT [Date] = DATEADD(Day,Number,@startDate)
FROM master..spt_values
WHERE Type='P'
AND DATEADD(day,Number,@startDate) <= @endDate
DECLARE @Date DATE='03/15/2016'
DECLARE @startDate DATE=CAST(MONTH(@Date) AS VARCHAR) + '/' + '01/' + + CAST(YEAR(@Date) AS VARCHAR)
DECLARE @endDate DATE=DATEADD(DAY,-1,DATEADD(MONTH,1,@startDate))
SELECT [Date] = DATEADD(Day,Number,@startDate)
FROM master..spt_values
WHERE Type='P'
AND DATEADD(day,Number,@startDate) <= @endDate
Comments
Post a Comment