Here are the way how to find first and last date of current month
DECLARE @today DATE
SELECT @today = GETDATE()
SELECT DATEADD(dd,-(DAY(@today)),@today) AS Date, ‘Last Date of Previous Month’ AS DateText
UNION
SELECT DATEADD(dd,-(DAY(@today)-1),@today) AS Date, ‘First Date of Current Month’ AS DateText
UNION
SELECT @today AS Date, ‘Today’ AS DateText
UNION
SELECT DATEADD(dd,-(DAY(DATEADD(mm,1,@today))), DATEADD(mm,1,@today)), ‘Last Date of Current Month’
UNION
SELECT DATEADD(dd,-(DAY(DATEADD(mm,1,@today))-1), DATEADD(mm,1,@today)), ‘First Date of Next Month’
GO
Hopefully it is useful for you.
Thanx

Tinggalkan komentar