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!

dates in Crystal XI 1

Status
Not open for further replies.

kratz

Programmer
Nov 17, 2006
35
US
User wants to compare data in a current period to data in the same period a year earlier. Current period is defined by begin and end parameters.

What's a good way to calculate the begin and end of the prior date range? I tried the following (for the begin date) but Crystal complains that "yyyy" is invalid giving no clue what's invalid about it.

date(datepart(yyyy, datetime({@CURRENTminDate}))-1,
datepart(m,datetime({@CURRENTminDate})),
datepart(d, datetime({@CURRENTminDate})))
 
I don't think the YYYY is invalid. Try changing the datepart to dateadd in your formula for figuring the year.


Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
Why not just use:
(
(
{table.date} >= {?start} and
{table.date} < {?end} + 1
) or
(
{table.date} >= dateadd("yyyy",-1, {?start}) and
{table.date} < dateadd("yyyy",-1, {?end} + 1)
)
)

-LB
 
Thank you very much. "dateadd" is exactly what I needed.
(As for the "yyyy" parameter I was trying to use in the datepart function, that was specified in Crystal's "help" document.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top