Formula giving Incorrect Results

Printed From: Crystal Reports Book — Forum Name: Technical Questions

I'm using Crystal 2011 and have what I thought was a pretty cut and dry formula, however if I use a date range in 2017, the results are correct. When I use any dates in 2016, I get the result of the "else" in the statement for all records, when I should be getting ".84" for a majority since the Date Parameter is less than the hard coded date.

Scan Date Formula:

Local Datetimevar scanDATE:={posj_event.business_date};
Local Stringvar scanDateSTR:=ToText(scanDATE,"MMddyy");
scanDateSTR

Formula that does not work when 2016 date is entered:

Local NumberVar rateNUM:=If upcSTR="3943000050" and {@Scan Date} < "030617"
then rateNUM:=.84 else rateNUM:=.01;
rateNUM
Have you double checked the value of scanDateSTR to see if you are getting the value you are expecting? You also do not show where the value for upcSTR comes from.  We can only assume that is correct also.
Also, I would really not use a < comparison on a string like that. Use the date data types, not strings.
A quick test in crystal returns a false on
"120616" < "030617".
I am getting the value I am expecting,

120216
120316
120416
120516

DBlank, I will give that a try. So what you are saying is use the actual value of the date, which is originally a date data type, rather than convert it to a string?
correct
Got it, works like a charm. Interesting that converting to a string behaves that way. Thank you for the help!!
"120616" < "030617"
it isn't numeric
the 1 is > the 0
I think, if you had to use as string you want to use
yyyyMMdd format but I still think using the actual date field is way more reliable.