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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate turnaround time 2

Status
Not open for further replies.

fkwong

Programmer
Jul 5, 2002
65
US
How to calculate two datetime values to get a turnaround time in HH:MM.

I try CTOT("12:51:54")-CTOT("08:07:13")/3600 = 4.7447 which is not correct.

Thanks for your help.

 
First, remember operator precedence:

CTOT("12:51:54")-CTOT("08:07:13")/3600 = 4.7447 will divide first... you want:

( CTOT("12:51:54")-CTOT("08:07:13") ) /3600 = 4.7447
 
Yes, but the result should be close to 4 hour and 44 minutes right?
 
Yes, and 60 * 0.7447 is 44.6820 minutes! 4.7447 is hours, so to get the minutes, take the fractional hours and multiply by the 60 minutes in an hour.

Rick
 
HI

t1=DATETIME()
t2=DATETIME()
d1 = t2-t1 && difference in seconds

hh= FLOOR((t2-t1)/3600)
mm= FLOOR((t2-t1)/60)-hh*60
ss=MOD(t2-t1,60)
? STR(hh,2)+":"+STR(mm,2)+":"+STR(ss,2)
:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Rick

Yes, and 60 * 0.7447 is 44.6820 minutes! 4.7447 is hours, so to get the minutes, take the fractional hours and multiply by the 60 minutes in an hour.

I knew how to do it, but I never seen the explanation written out. You get my mark.TKS

Ramani

Ramani always "le mot juste" (loose translation "always the right word") You get my mark.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top