Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Selecting range of an event based on date Post Reply Post New Topic
Author Message
elie234
Groupie
Groupie


Joined: 21 Aug 2009
Online Status: Offline
Posts: 68
Quote elie234 Replybullet Topic: Selecting range of an event based on date
     Posted: 21 Aug 2009 at 12:39pm
I am writing a report that is meant to display how many hours in a particular date range a machine is running. Each time the machine is turned on it creates a new event in the db with a start time field and end time field. These times are in seconds in epoch form from 1/1/1990. I have discovered in formula writer that I can convert these times to datetime with the DateAdd function.
My next step is to figure out a way to calculate only the part of the event that falls within the date parameter. For example, if the parameter is runtime between 1/1 0700 hrs and 1/2 0700 hrs and there is a run event from 0600 hrs on 1/2 to 1200 hrs on 1/2 I would only want it to count 1 hour of run time on my report. Any ideas on how this could be done? Any help would be greatly appreciated!!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Aug 2009 at 7:02pm
You can create 2 long if then if then formulas to "alter" the begin and end date then a final formula to datadiff those.
Your fomrulas have to account for every option as to how to "convert" the time.
If starttime < range start then range start else
if start time in rang start to range end then start time etc...
Hope that helps.
IP IP Logged
elie234
Groupie
Groupie


Joined: 21 Aug 2009
Online Status: Offline
Posts: 68
Quote elie234 Replybullet Posted: 24 Aug 2009 at 6:52am
Thanks! Very helpful!
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