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!

How to convert hours/mins/seconds greater than one day to seconds

Date/Time Functions

How to convert hours/mins/seconds greater than one day to seconds

by  Mikeauz  Posted    (Edited  )
Hi,

In converting Hours:Mins:seconds to seconds I was always a beleiver of using =(HOUR($A1)*3600)+(MINUTE($A1)*60)+(SECOND($A1)) but recently discovered that Excel stores times greater than 24 hours as days/months/years/hours/minutes/seconds

To get around this problem paste the following into a module:

Public Function TSITSeconds(CellName) As String
Dim Result, TotResult As String
Dim newname As Integer

TotResult = 0
newname = Int(CellName)

TotResult = (newname * 86400)

TotResult = TotResult + (Hour(CellName) * 3600)
TotResult = TotResult + (Minute(CellName) * 60)
TotResult = TotResult + (Second(CellName))
TSITSeconds = TotResult
End Function

and to use it type this in your excel sheet:

=TSITSeconds(YourCellAddress)

This will give you youre answer in seconds

Hope it Helps
Mike
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top