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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula for last 4 or 6 months of data

Status
Not open for further replies.

GaryCWL

Technical User
Mar 7, 2006
14
US
Backend: SQL Server 2000
Crystal Version: BO Crystal XI

Is it possible to set up a formula that returns the last six months worth of data? I tried something like:

{order.date} in DateTime (CurrentDate - 180) to DateTime (CurrentDate)

But, the problem with that, is depending on when the report is run or how many days in a month, I may not get all the data for latest month. For example, the above formula will return data from October 2006 - April 2007; however, October's data does not include an entire months worth.

Please help.
Thanks,
Gary
 
Try
Code:
DateDiff ("m", {date1},  currentdate) <= 6


[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
What you're probably after is the last COMPLETED 6 months of data.


{table.date} >= dateserial(year(minimum(lastfullmonth)),month(minimum(lastfullmonth))-6,1)
and
{table.date} <= lastfullmonth

-k
 
Thanks for you responses. Both formulas worked GREAT.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top