Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Issue Comparing Dates Post Reply Post New Topic
Author Message
GrtDay4Hockey
Newbie
Newbie


Joined: 30 Jun 2010
Online Status: Offline
Posts: 3
Quote GrtDay4Hockey Replybullet Topic: Issue Comparing Dates
     Posted: 30 Jun 2010 at 8:11am
Hello all,
 
I am fairly new to Crystal and have run into an issue. 
 
I have two date fields (Date_due and Date_received).  Based on those dates, I have an if statement (if date_received is <= Date_due then 'On-time' else 'late') and it works fine until it comes to the end of the year.  If I have a due date of 01/05/2010 and received date of 12/29/2009, Crystal incorrectly labels this as late, even though it isn't.
 
I'm using Crystal XI.
 
Thanks in advance!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 30 Jun 2010 at 10:40am

you could use DATEDIFF() and if the result is <= 0 then it is On-time. Look up in help for the exact syntax...I get the dates confused and the first parameter is slightly different from its SQL counterpart.

HTH
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 30 Jun 2010 at 10:44am
Try this:
if datediff('d',{@DateDue},{@DateRec})<=0
    then 'On-Time'
        else 'Late'
|< /\ '][' ( )
IP IP Logged
GrtDay4Hockey
Newbie
Newbie


Joined: 30 Jun 2010
Online Status: Offline
Posts: 3
Quote GrtDay4Hockey Replybullet Posted: 01 Jul 2010 at 2:00am
Good morning,
 
Thanks for the replies!  I will try this out this morning and let you know.
 
Thanks again!
IP IP Logged
GrtDay4Hockey
Newbie
Newbie


Joined: 30 Jun 2010
Online Status: Offline
Posts: 3
Quote GrtDay4Hockey Replybullet Posted: 01 Jul 2010 at 2:36am
It worked!  Thanks so much for your help!!
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