dianemarie
Instructor
Hi, I found the code below to put into a dataset query, then I pull the CurrentStartDate and CurrentEndDate as defaults into my parameters. Works really good for the first date of current month, and the last second of the prior day of current month. Exactly what I wanted (I'd like to format the parameter not to show time, but I haven't really looked at that yet.) My report is a 2 year comparison, so what I could use some help on is how to get the same dates for one year ago. (Ex: CurrentStart = 4/1/09, CurrentEnd = 4/27/09, PriorStart = 4/1/08, PriorEnd = 4/27/08) You see where I'm going. Been playing with DateDiff but I'm not getting it, despite printing off the Microsoft explanations. Thank you so much if you can help.
select dateadd(mm,datediff(mm,0,getdate()),0) [CurrentStart],
dateadd(s,-1,dateadd(dd,datediff(dd,0,getdate()),0)) [CurrentEnd],
select dateadd(mm,datediff(mm,0,getdate()),0) [CurrentStart],
dateadd(s,-1,dateadd(dd,datediff(dd,0,getdate()),0)) [CurrentEnd],