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

previous 2 months

Status
Not open for further replies.

wysiwygGER01

Programmer
Feb 18, 2009
188
AU
Hi,
I'm new to Crystal and am currently trying to alter a report to show me purchase order totals for the previous 2 months.
I have a test solution for month to date (February) and January but because it then goes back to 2009 my formula doesn't work.

My record selection formular goes like this for the current month:
month({@PO Date})=month(currentdate) and
year({@PO Date})=year(currentdate)

I've created a subreport each for the 2 previous months. January would look like this:
month({@PO Date})=(month(currentdate))-1 and
year({@PO Date})=year(currentdate)

For December 2009 I've tried this:
month({@PO Date})=(month(currentdate))-2 and
year({@PO Date})=(year(currentdate))-1
But this doesn't seem to work.

Obviously this solution is far away from being perfect as it is static. Would there maybe a built in function i could use?
 
Try using dateserial instead, as in:

//{@twomonthsago}:
{@PO Date} in dateserial(year(currentdate),month(currentdate)-2,1) to
dateserial(year(currentdate),month(currentdate)-1,1)-1

//{@onemonthago}:
{@PO Date} in dateserial(year(currentdate),month(currentdate)-1,1) to
dateserial(year(currentdate),month(currentdate),1)-1

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top