Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: date 30 days before another date Post Reply Post New Topic
Author Message
sheriberi
Newbie
Newbie


Joined: 14 Feb 2013
Online Status: Offline
Posts: 6
Quote sheriberi Replybullet Topic: date 30 days before another date
     Posted: 10 Sep 2014 at 4:58am

I am trying to look at patients with a test date within 30 days before their procedure date. So if the test was 20 days before the procedure, they count as Yes.  But if the test was 31 days (or more) before the procedure date, they don't count (No). What I am using is calculating correctly sometimes, but not all the time and I don't understand it.

if ({TEST.DATE}) > DateAdd('d',-30, {PROCEDURE.DATE})
then "Yes"
ELSE "No"

 

IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 10 Sep 2014 at 5:20am
can you explain when it is calculating correct and when not? can you give some examples?
IP IP Logged
sheriberi
Newbie
Newbie


Joined: 14 Feb 2013
Online Status: Offline
Posts: 6
Quote sheriberi Replybullet Posted: 10 Sep 2014 at 5:55am
It was completely random of when it was right and not.  I did get a solution from someone on another site's board and it works perfectly....in case anyone ever needs it:
 
I needed to ensure the testdate is before the procedure date:

if ({TEST.DATE}) >= DateAdd('d',-30, {PROCEDURE.DATE}) AND {TEST.DATE} <= {PROCEDURE.DATE}
then "Yes"
ELSE "No"
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 10 Sep 2014 at 5:57am
you could also use

if {TEST.DATE} between {PROCEDURE.DATE}-30 and {PROCEDURE.DATE} then "Yes" else "No"
IP IP Logged
sheriberi
Newbie
Newbie


Joined: 14 Feb 2013
Online Status: Offline
Posts: 6
Quote sheriberi Replybullet Posted: 10 Sep 2014 at 8:25am
I've never been successful at getting Crystal to accept "between". It just keeps telling me I'm nissing the required "then", which I'm not.
 
But I can use in and to like this and it seems to work:
 
 {TEST.DATE} in {PROCEDURE.DATE}-30 to {PROCEDURE.DATE} then "Yes" else "No"
 
 so thank you for the alternative!


Edited by sheriberi - 10 Sep 2014 at 8:28am
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 10 Sep 2014 at 10:16pm
Mixing Oracle and Crystal syntax is never a good idea, it has to be IN - TO and not between, you are right :)
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