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

I’m Riza

Welcome to my website. I’m happy to share my knowledge and experience here, especially related with my expertise in digital solution for enterprise. I’ll talk many topics around technology, AI, and others. Happy to know you!

You can find me in network platform below

Let’s connect