Get first date and Last date of the given month and Year

Karthikreddy
Posted by Karthikreddy under Sql Server category on | Points: 40 | Views : 946
DECLARE @Month int
DECLARE @Year int

set @Month = 3
set @Year = 2004

select DATEADD(month,@Month-1,DATEADD(year,@Year-1900,0)) /*First*/

select DATEADD(day,-1,DATEADD(month,@Month,DATEADD(year,@Year-1900,0))) /*Last*/

Comments or Responses

Login to post response