Ok I am trying to write a query that says get the current date and make it the start date. Then I want to go a month back from that current date for the EndDate. Is it possible to do this? Like if it was 9-15-2010 as the start date can I go a month back from that to 8-15-2010 or is this no possible....what would you do for like 9-20-2010 as the start date since every month has a different amount of days in it? Otherwise if this is not possible how else could I do this? The report will always be run on the 25th of the month so any ideas? I need to go from the 25th back a month....I can get some duplicate records between months if needed but less is obviously better
Right now I am using this:
DECLARE @StartDate DATETIME,
@EndDate DATETIME;
SET @StartDate = DATEADD(m,-1,GETDATE());
SET @EndDate = DATEADD(m, 1, @StartDate);
Does this work?
Also, how would I then say my AuditInsertTimestamp is between @Start adn @EndDate?
Currently I have this:
AND cvn.[AuditInsertTimestamp] BETWEEN @StartDate AND @EndDate ;
This is still giving me dates like 7-26-2010 though....
Thanks!