Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time

Status
Not open for further replies.

slickp007

MIS
Feb 18, 2008
46
GB
Hi i have two fields which i've pulled from my tables which are time fields, but are held as strings in the database. So i've converted them both to time with the following formulas:

//@time_started
Time (ToNumber (Left (Maximum ({OPERATORLOG.TimeStarted}, {OPERATORLOG.OperatorCode}), 2)), ToNumber (Mid (Maximum ({OPERATORLOG.TimeStarted}, {OPERATORLOG.OperatorCode}), 3, 2)), ToNumber (Right (Maximum ({OPERATORLOG.TimeStarted}, {OPERATORLOG.OperatorCode}), 2)))

//@time_finished
Time (ToNumber (Left (Maximum ({OPERATORLOG.TimeFinished}, {OPERATORLOG.OperatorCode}), 2)), ToNumber (Mid (Maximum ({OPERATORLOG.TimeFinished}, {OPERATORLOG.OperatorCode}), 3, 2)), ToNumber (Right (Maximum ({OPERATORLOG.TimeFinished}, {OPERATORLOG.OperatorCode}), 2)))

I now wanna take the time finished away from the time started to find the total time taken. However when i do this i get a number returned. How can i turn this into hour, mins and secs? i've tried placing the total time taken formula into a time funtion i.e

time({@time_taken})

but it just returns 00.00.00, any ideas please?

thanks
 
Try
Code:
DateDiff ("n", {time1},  {time2})
This will give you the difference in minutes. For hours and minutes, do
Code:
ToText((FindDiff/60), "00") & ":" & ToText(Remainder(@FindDiff, 60), "00")
If you need seconds, use "s" and take the process one stage further.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
i tried your @FindDiff code and it comes back with an error saying "A date is required here."

Is there anyway i can make this funstion show the difference between two times?
 
Its cool i've worked it out, thanks a lot for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top