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

format time as decimal

Status
Not open for further replies.

diwin

Technical User
Nov 29, 2002
218
CA
I have a short time field in a table. Is it possible to display 10:30 AM as 10.5 and 10:30 PM as 22.5?

Daniel Dillon
O o . (<--- brain shrinking at rate shown.)
 
THanks.
Is it possible by formatting code, rather than running a procedure? Dateformat or sumpthink?

Daniel Dillon
O o . (<--- brain shrinking at rate shown.)
 
You can use a single line, the code was there for descriptive purposes, for example, you could put this in a textbox:

Code:
= Hour(txtTime) + ((Minute(txtTime) * 60) + Second(txtTime)) / (60 * 60)

Where txtTime is the name of the field or control with the time.

 
the data will be imported from a csv file into a new table. The time format is... 18:12:28. I am looking for... 18.2

Daniel Dillon
O o . (<--- brain shrinking at rate shown.)
 
Let us say you link the CSV you wish to import:

SQL to create a new table called NewTable:
Code:
SELECT ImptCSV.Field1 AS ID, 
   Hour([Field2])+((Minute([Field2])*60)+Second([Field2]))/(60*60) AS TimDec, 
   ImptCSV.Field3 AS Other INTO NewTable
FROM ImptCSV;





 




There is no TIME format for fractions of an hour. You must CONVERT TIME, which is in units of DAYS, to HOURS. Hence, Remou's conversion formulas.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top