Click to See Complete Forum and Search --> : How to calculate time.


mwells1
June 27th, 2008, 08:02 AM
I have a database that is setup with the following fields

TrackingID DMRNum DTSTAMP
463788 78636 6/5/2008 2:19:00 PM
464333 78636 6/5/2008 3:15:00 PM
468972 78636 6/6/2008 8:02:00 AM
488263 78636 6/10/2008 9:39:00 AM

I need to be able to calculate the time between each TrackingID.

For instance for DMRNum 78636, what was the time in hours between TrackingID 463788 and 464333 and the the time between 464333 and 468972 etc.

I would also like to be able to back out working hours with this formula.

I have a formula that does that now but the only way I can do it is if I group DMRNum and calculate the time between the Max and Min TrackingID.

I don't have a problem doing that I just am struggling calculating the time of the ones that are not the Max and Min (the ones in between).

Thanks for your help.

jggtz
June 27th, 2008, 12:56 PM
Just a hint
Try using the function PREVIOUS and use it only when the RecordNumber > 1

JG

mwells1
June 27th, 2008, 02:41 PM
A hint?

I did not know this was a guessing game.

Thanks alot.

mwells1
June 30th, 2008, 08:59 AM
When ever I try to use this formula to calculate only hours that are "Business Hours" I get the following error message: This formula cannot be used because it must be evaluated later.

The @PreviousDTStamp is highlighted.

The @PreviousDTStamp is the formula field that I am useing as my start time.

WhileReadingRecords;
NumberVar Days := {@BusinessDays}; // The field that calculates your business days
TimeVar SetStart := TimeValue( "6:00"); // The start your work day
TimeVar SetEnd := TimeValue("16:00"); // The end your work day
TimeVar StartTime := TimeValue({@PreviousDTStamp});// The data field that holds your Start Time
TimeVar EndTime := TimeValue({tblTracking.DTSTAMP}); // The data field that holds your End Time

//These lines are only needed if your times are strings that do not indicate AM or PM, like "3:30"
//They will convert afternoon times to PM. Of course, this won't work if your workday is over 12 hours.
If StartTime < (SetEnd - 43200) then StartTime := StartTime + 43200;
If EndTime < (SetEnd - 43200) then EndTime := EndTime + 43200;

Days * ((SetEnd - SetStart) / 3600)
- ((SetEnd - EndTime) / 3600)
- ((StartTime - SetStart) / 3600)

If anyone has any better ideas I would appreciate it.

Thanks in advance.