Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help with Date Differences Post Reply Post New Topic
Author Message
mross
Newbie
Newbie


Joined: 25 Jul 2011
Location: United States
Online Status: Offline
Posts: 5
Quote mross Replybullet Topic: Help with Date Differences
     Posted: 25 Jul 2011 at 9:24am
Hello,
 
I need a formula to calculate the date difference between dates within the same field.  The report lists work orders done by each of our drivers (we're a hauling company) and their completion times.  I would like to be able to calculate the difference between start times, but it seems to be more complicated than a datediff formula since these times are within the same field.  I feel like there must be some way to order or sort the orders based on completion time so that I can find the times between the 1st and 2nd order of the day, the 2nd and 3rd, ...second to last and the last.
 
I am fairly new at crystal reports.  Any help would be greatly appreciated and thank you in advance for your help.
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 26 Jul 2011 at 3:23am
you want to calculate the difference between start times between work orders by driver is that correct?
the field you want to calculate is the same field in the same table?
sharona
IP IP Logged
mross
Newbie
Newbie


Joined: 25 Jul 2011
Location: United States
Online Status: Offline
Posts: 5
Quote mross Replybullet Posted: 26 Jul 2011 at 7:07am
that's right,
I want to be able to find the time per work order by finding the time difference between the nth and (n+1)th work order start time.  This is done for each driver for each day.


Edited by mross - 26 Jul 2011 at 7:07am
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 26 Jul 2011 at 7:08am
 nth and (n+1)th  ??????????
sharona
IP IP Logged
mross
Newbie
Newbie


Joined: 25 Jul 2011
Location: United States
Online Status: Offline
Posts: 5
Quote mross Replybullet Posted: 26 Jul 2011 at 8:45am
Sorry if that was confusing.  Here is what the report looks like:
 
Driver
  Date
    Work Order details
 
Here's an example:
 
Robert
  7/25/2011
    Job 11678  6:15am  (start time)  etc..
    Job 11717  7:25am  (start time)  etc..
    Job 11725  10:25am (start time) etc..
 
  Driver Clock in: 6:00am
  Driver Clock out: 6:15pm
------
Next Driver and so on
 
 All of the start times are taken from the field {COST_COSH_VIEW.Start_Time}
 
I want to make a formula to show that the first job from 6:15-7:25am took 1h10min, but I don't know how to do that other than manually entering stop times into a different field, essentially doubling the data entry.  Thank you again for your help.
 


Edited by mross - 26 Jul 2011 at 8:46am
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 26 Jul 2011 at 9:14am
you can try this, but im not sure if it will help
create a formula called next start
next({starttime})
place that next to your startdtime
try the datediff between the startdtime and your formula
i would also group by
Driver
  Date
    Work Order details id
sharona
IP IP Logged
mross
Newbie
Newbie


Joined: 25 Jul 2011
Location: United States
Online Status: Offline
Posts: 5
Quote mross Replybullet Posted: 26 Jul 2011 at 12:24pm
It worked for displaying the route times, but I can't do any summary data based off of it.  I get the error message "field cannot be summarized" when I do.
 
Ideally, I want to calculate their average time per route.  I can do this if I reenter each start time (besides the first one) as a stop time for the previous route, but of course it takes twice as long.  This may be a lost cause or maybe there's another workaround.  Either way, thank you for your help.
 
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 27 Jul 2011 at 4:11am
what is your datasource?  i was thinking if it is a command or view or sp you can create a new field by using the startdatetime field
 
select
starttime                    as start1
starttime                    as start2
then use the date diff that way


Edited by sharona - 27 Jul 2011 at 4:13am
sharona
IP IP Logged
mross
Newbie
Newbie


Joined: 25 Jul 2011
Location: United States
Online Status: Offline
Posts: 5
Quote mross Replybullet Posted: 27 Jul 2011 at 7:39am
I'm not really familiar with the datasource types.  I'm drawing from SQL database tables.  Other than that I don't really know what you're asking for; I'm fairly new at this.  I also don't know how to create a new field yet.
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