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!

Qty for rolling last 6 months being double counted 1

Status
Not open for further replies.

travelerII

Technical User
Jun 4, 2009
66
US
I am using Crystal 10.
I am trying to get sales invoice quantities on a rolling last 6 months.
I am using the following formula for sales from the current month -1 (in this case March)
IF {SINVOICED.INVDAT_0} in dateserial(year(CurrentDate), month(currentdate)-0, 1) to
dateserial(year(CurrentDate), month(currentdate)-1, 1)-1
then {@Qty}
else 0
The problem I am running into is that it is returning sales of 04/01/2011. So for each of the 6 trailing months if there are any sales on the 1st of the month ahead of what I want it gets double counted. In this case it shows up on the current month and the current month -1.
Any ideas on what is causing this and how to fix it?
Thanks
 
Formula should be:

IF {SINVOICED.INVDAT_0} in dateserial(year(CurrentDate), month(currentdate)-1, 1) to
dateserial(year(CurrentDate), month(currentdate), 1)-1
then {@Qty}
else 0

-LB
 
Thanks for your help. That solved the problem. If you don't mind my asking, for my own education, could you explain this formula?
In other words what are the various arguments and what are they asking for? Such as the -1,1 after currentdate and the -1 after the last parenthesis?

Thanks again.
 
This is just a date format: dateserial(year, month, day).

The the month(currentdate) returns today's month in number form, so for last month, you want to subtract 1. Dateserial allows you to do this in cases where the current month might be January.

The date in the second half of the formula shows day one of the currentmonth. By subtracting 1, you get the last day of the previous month. This approach allows you get the accurate last day of the previous month, regardless of whether it is 28, 29, 30, or 31.

And you should always set up formulas like this show the "from" date first and then the "to" date.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top