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

Convert Time in to a Decimal 2

Status
Not open for further replies.

DMHCCI

Vendor
May 9, 2003
22
US
For example I have a time field that contains a value 1:15 - meaning 1 hour and 15 minutes. I want to convert that to 1.25 hours and store in a decimal field. I started by subtracting a "start time" from a "stop time" field and stored the results in a "accumulated time" field. Now I need a function to convert the "accumulated time field" to a decimal representing hours.
 
Assume that your time filed is called "Time"

In a query, you could use this.

Hours:val(left([time], 2) + round (right([time], 2) / 60)

Enjoy,
ChaZ

Ascii dumb question, get a dumb Ansi
 
To convert the running total of elapsed time, you may try something like this:
SELECT (24*Int(Sum(Table2.myDateTime))+Format(Sum(Table2.myDateTime),'h')) & Format(Sum(Table2.myDateTime),':nn:ss') AS TotalTime

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
No need for the complicated vals, rounds, formats etc

Date is essentially a double stored in a special way where adding 1 day is the same as adding 1 to the double. You would need it to add 24 so....

CDbl(#01:15:00#) * 24 gives 1.25 which is what you are after.

So for a field CDbl([YourField]) * 24 returns it for a field.

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top