Link to home
Start Free TrialLog in
Avatar of dkilby
dkilbyFlag for Canada

asked on

ms sql + dates

i would like to get the first day and last of the month of the previous month, i am using the following code, but would like the time for the startdate be 00:00 and end date 23:59 how can i modify to accomplish.

declare @StartDate datetime,
            @EndDate datetime

select @StartDate = DATEADD(dd,-(DAY(DATEADD(mm,1,GetDate()))-1),DATEADD(mm,-1,GetDate()))
select @EndDate = DATEADD(dd, -DAY(DATEADD(m,1,GetDate())), DATEADD(m,0,GetDate()))
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkilby

ASKER

thanks for the help