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
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
what is your code?
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
ASKER
I think I'm doing my date comparisons wrong... any tips?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
James