Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formatting overdue items Post Reply Post New Topic
Author Message
cactusman
Newbie
Newbie
Avatar

Joined: 20 Mar 2013
Location: United States
Online Status: Offline
Posts: 4
Quote cactusman Replybullet Topic: Formatting overdue items
     Posted: 25 Mar 2013 at 2:35am
Morning all!

I'm trying to format a report in CR 2008 to make overdue items have a red date. The code is below:

if
(isNull({NCR.CloseDate_CAR}) and
{NCR.ExtendDate_CAR} < CurrentDate)
xor
(isNull({NCR.CloseDate_CAR}) and
{NCR.DueDate_CAR} < CurrentDate)
then crRed else crNoColor

Basically, the formatting is to make a field's text red only if -EITHER- the NCR.CloseDate_CAR is blank and the NCR.ExtendDate_CAR is less than the current date -OR- the NCR.CloseDate_CAR is blank and the NCR.DueDate_CAR is less than the current date. What I'm getting is the text is red only if the 2nd condition is met...it ignores the first condition totally.

I'm sure I have some wrong logic in the code but I can't see where. Can anyone assist?

Thanks in advance!

Cactusman

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Mar 2013 at 3:50am
try changing the formula option to use 'default values for nulls'

Edited by DBlank - 25 Mar 2013 at 3:51am
IP IP Logged
cactusman
Newbie
Newbie
Avatar

Joined: 20 Mar 2013
Location: United States
Online Status: Offline
Posts: 4
Quote cactusman Replybullet Posted: 25 Mar 2013 at 9:42am
That was worse. I changed back to exceptions and revised the formatting code for the meantime to be:

if (isNull({NCR.CloseDate_CAR}) and
{NCR.DueDate_CAR} < CurrentDate) then
crRed else crNoColor

M
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Mar 2013 at 10:24am
I am confused. Your description of what you want does not match my understanding of how you used the xor in your formula
 
my guess is that you want it to turn red even if either or both are < currentdate.
I also am guessing that extenddate is often null.
This would explain why using default values for nulls would 'make it worse'.
I am guessing that if you have an extenddate value that it supercedes the duedate so if it is < today it is late. If it is null tehn you ned to ignore it and only check if the duedate is <today.
ios this an accurate description?
 


Edited by DBlank - 25 Mar 2013 at 10:24am
IP IP Logged
cactusman
Newbie
Newbie
Avatar

Joined: 20 Mar 2013
Location: United States
Online Status: Offline
Posts: 4
Quote cactusman Replybullet Posted: 25 Mar 2013 at 10:57am
Dblank, you are 100% correct!!!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 25 Mar 2013 at 11:02am
try this
 
if isNull({NCR.CloseDate_CAR}) and
(if isnull({NCR.ExtendDate_CAR}) then {NCR.DueDate_CAR} else {NCR.ExtendDate_CAR}) < CurrentDate then
crRed else crNoColor
IP IP Logged
cactusman
Newbie
Newbie
Avatar

Joined: 20 Mar 2013
Location: United States
Online Status: Offline
Posts: 4
Quote cactusman Replybullet Posted: 25 Mar 2013 at 11:08am
Bingo! Much thanks, DBlank!!
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum