Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rolling Twelve Months - Whole Months Only 2

Status
Not open for further replies.

DudleyBoy

MIS
Dec 9, 2009
7
GB
HI,

I'm new to crystal and Tek-tips so any help would be really aprreciated.

I need to create a formula/paramter using a date field for a rolling 12 months but for whole months only.

So, if I run the report today, 9th December, it will only report on dates that are 30th November 2009 back to 1st December 2008 inclusive.

Can someone help?

This is what I use right now to show the last twelve months so I'm guessing including the lastfullmonth operator somewhere might work?

{datefield}>= DATEADD ("yyyy", -1, CURRENTDATE)
 
{datefield} >= DATEADD ("m", -12, CURRENTDATE-day(currentdate))+1 and
{datefield} < maximum(lastfullmonth) + 1

-LB
 
Thanks for this, it does exactly what I need it to.

Can you help me one stage further and explain what the formula is actually doing?

Thanks again.
 
I switched it to months because the "yyyy" might not work as you wish for February (leap year) dates. The currentdate-day(currentdate) subtracts the day of the month from the current date, taking the date back to the last day of the previous month. The "+1" after the dateadd function adds one day, making it the first of the next month. The maximum(lastfullmonth) returns the last day of the last full month.

-LB
 
Thanks for this explanation. I really appreciate it. I understand now what its doing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top