cancel
Showing results for 
Search instead for 
Did you mean: 

SQL QUERY FOR LAST DATE OF MONTH AND PARAMETER DATE

0 Kudos
161

Hi Team,

need sql query for if i put middle of the month date and the last date of the month should come. if i put the last date of the month then that date will appear query Kindly help me to create query for me . Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

LoHa
Active Contributor

Hi Hari,

try this

DECLARE @date DATETIME = getdate()  
SELECT 
EOMONTH(@date) AS [EndOfTheMonth]
,DATEADD(m,-1,DATEADD(d,1,EOMONTH(@date))) AS [FirstOfMonth]

regards Lothar