YTD through end of last month

Printed From: Crystal Reports Book — Forum Name: Technical Questions

I need to select records based on a date range that starts with January 1 of this year and runs through the last day of last month (based on the current date).
 
I also need to select the same date period for the previous year.
 
Thanks in advance for your help.

//last day of month
//Date(DateAdd("d",-day(today),DateAdd("m",1,today)))

//First day of year
//date(year(today),1,1)

//last day of month last year
//Date(DATEADD("yyyy",-1,DateAdd("d",-day(today),DateAdd("m",1,today))))

//First day of previous year
//date(year(today)-1,1,1)

therefore
(
[datefield] in date(year(today),1,1) to Date(DateAdd("d",-day(today),DateAdd("m",1,today)))
or
[datefield] in date(year(today)-1,1,1) to Date(DATEADD("yyyy",-1,DateAdd("d",-day(today),DateAdd("m",1,today))))
)
Thanks for your help.  A little tweeking in my report and it worked.