Link to home
Start Free TrialLog in
Avatar of hamlin11
hamlin11

asked on

Crystal Reports - Formula - Display a value if a Date is between a Start Date and an End Date

Greetings,

Please see the code snippet below.

I want to display a SalesAmount value when the MyDate value is between StartDate and EndDate.

The reason I define start date and end date in the code is for testing - eventually I'll setup some input paremeters for users of the report.

This code ALWAYS includes the SalesAmount and never outputs 0 -- even for results from the year 2003

A) Is there a bug in my code?

B) Is there some simple way to debug formulas without having to run the whole report?

Thanks
Avatar of tigin44
tigin44
Flag of Türkiye image

what is your code?
Avatar of hamlin11
hamlin11

ASKER

Sorry I forgot to paste the code..



DateVar D1 = {SomeTable.MyDate};
DateVar EndDate = Date(2008, 9, 1);
DateVar StartDate = Date(2008, 8, 1);
 
IF ((D1 >= StartDate) AND (D1 <= EndDate)) THEN
    {someTable.SalesAmount}
ELSE
   0

Open in new window

I think I'm doing my date comparisons wrong... any tips?
SOLUTION
Avatar of tigin44
tigin44
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of James0628
James0628

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't know what the deal is, but i wouldn't work even after I switched "=" to ":="

However, It eventually started working. I don't know what the deal is, but maybe I had to refresh the report.

Thanks for your help
Hmm.  I don't know.  It sounds odd.  IAC, I'm glad you got it working.

 James