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

Conversion Decimal into Minutes

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi!!!

Do you know which is the best way to convert into seconds the next:

I have var1 + var2 9.45 + 9.45 (String or Numeric no problem)...

And I need to get the exactly hours and minutes for example: the correct result is 19 hours with 30 Minutes 19.30 and not 18.90 like a real addition calc....

Do you know if I can use some conversions? is it better to use string or numeric? Does and function right now exist for this?

Thanks for any help

MR
 
MR:

Try:

?int(18.90) &&gives you 18
and
?mod(18.90,1) &&gives you .90

and then you can convert from there. . .

Hope this helps

Bill
 
You will need to parse the string for the individual elements and then add them together. For example:
Code:
nFirst=9.45
* Convert from seconds to decimal
nMin1=int(nFirst)+((nFirst-int(nFirst))*100/60)
nSecond=9.45
* Convert from seconds to decimal
nMin2=int(nSecond)+((nSecond-int(nSecond))*100/60)
nTotal=nMin1+nMin2
* Convert final number back to minutes.seconds
nLast=int(nTotal)+((nTotal-int(nTotal))*60/100)
?"Total is "
??nLast
 
here are 2 routines you can play with (assuming they still work)
1st one converts a time string into numberic seconds from midnight
2nd one converts a numberic seconds from midnight into a time string and it accounts for the next day factor.

example
lcTime1 = time()
lcTime2 = "09:00:10"

lcClockTime = tm_s2t(tm_t2s(lcTime2) - tm_t2s(lcTime2))
David W. Grewe
Dave@internationalbid.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top