Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Need help with date formula Post Reply Post New Topic
Author Message
angiegail77
Newbie
Newbie


Joined: 26 Jul 2012
Location: United States
Online Status: Offline
Posts: 3
Quote angiegail77 Replybullet Topic: Need help with date formula
    Posted: 26 Jul 2012 at 7:28am
I need to be able to calculate the days between specific activity dates.
 
For instance, a client may have a total of 20 visits, and I need to figure out the days between the first Kept visit and the second scheduled visit.  Additionally, need to add other paramaters such as days between first kept therapy appointment and first scheduled medication appointment.
 
activitydate_d, activity_c, recipient_c, clientcode_c
 
Any help would be appreciated.
 
Thanks :)
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 26 Jul 2012 at 9:12am
simplest solution is DATEDIFF("d", oneDate, otherDate)...
if it comes out negative, reverse oneDate and otherDate.
 
 
HTH
IP IP Logged
angiegail77
Newbie
Newbie


Joined: 26 Jul 2012
Location: United States
Online Status: Offline
Posts: 3
Quote angiegail77 Replybullet Posted: 26 Jul 2012 at 9:42am
The dates values are all stored in the same table, same column.  I am not sure how to use datediff to differentiate between - i.e. number of days between a kept Intake (0110) and a subsequent scheduled therapy appointment (0116).
 
Number of days between
 
activity_c = "0110" and recipient = "KEPT"
 
and
 
activity_c = "0116" and recipient is (any value)
 
So, if the intake was kept on 7/01/2012 and they had a therapy appointment scheduled on 8/12/2012 - how to calculate the number of days that have elapsed between.
 
I don't usually have a hard time figuring this stuff out, but for some reason this scenario is throwing me off and I can't seem to wrap my head around it :/
 
Thanks for the feedback :)
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 26 Jul 2012 at 10:02am
well....
not an easy one to solve.
 
you will probably have to use shared variables to keep track of which date goes where, if the rows are not consecutive for the information...
 
shared datevar kept;
if {table.recipient} = "KEPT" then kept := {table.datefield};
 
using this idea you can code for all the different scenarios and use datediff.  It might need to be datetimevar instead of a datevar.
 
you will have to reset the variables, probably when group changes, but you should be able to display differences as they occur on the report and/or sum them using the same idea.
 
HTH
 
 
IP IP Logged
angiegail77
Newbie
Newbie


Joined: 26 Jul 2012
Location: United States
Online Status: Offline
Posts: 3
Quote angiegail77 Replybullet Posted: 26 Jul 2012 at 10:59am
Thanks... not working for me so far... but, i'll keep trying :)
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.000 seconds.