I am using this code
declare @mydate datetime select @mydate = getdate()
declare @startdate varchar(20) SELECT @StartDate = CONVERT(varchar(20),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))-1),DATEADD(mm,-1,@mydate)),120)
declare @enddate varchar(20) SELECT @EndDate = CONVERT(varchar(20),DATEADD(dd,-(DAY(@mydate)-1),@mydate),120)
Select @startdate as 'Start Date', @enddate as 'End Date'
To determine the first day of the previous and current month for a report, but it gives a time based on the current time. How can I get
2011-04-01 00:00:00
&
2011-05-01 00:00:00
?