Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default time to seconds

I have a spreadsheet which contains time information like follwoing
format

0h 15m 35s
7h 1m 5s

and I would like to convert in seconds,

Are there any functions or formula to do this?


Your help is great appreciated,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default time to seconds

I made a custom function. Put this code into a standard module. I assumed
your hours, minutes, and seconds will have spaces between them. Plus I
assumed it all will be in 1 cell. If your data is in A1 put this formula in
B1 "=ConvertTime(A1)". See what happens. Hope this helps! If so, let me
know, click "YES" below.

Function ConvertTime(MyRange As Range) As String

Dim MyArray As Variant

MyArray = Split(MyRange)
ConvertTime = Val(MyArray(0)) * 360 + Val(MyArray(1)) * 60 +
Val(MyArray(2))

End Function
--
Cheers,
Ryan


"inungh" wrote:

I have a spreadsheet which contains time information like follwoing
format

0h 15m 35s
7h 1m 5s

and I would like to convert in seconds,

Are there any functions or formula to do this?


Your help is great appreciated,

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default time to seconds

I assume the following:-

These are not correctly formatted times
They will all be in the format of your examples.


Try this

=(LEFT(A1,FIND("h",A1)-1)*3600)+(MID(A1,FIND(" ",A1)+1,FIND("m",A1)-(FIND("
",A1)+1))*60)+(SUBSTITUTE(MID(A1,FIND(CHAR(7),SUBS TITUTE(A1,"
",CHAR(7),2))+1,999),"s",""))

all one line
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"inungh" wrote:

I have a spreadsheet which contains time information like follwoing
format

0h 15m 35s
7h 1m 5s

and I would like to convert in seconds,

Are there any functions or formula to do this?


Your help is great appreciated,

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default time to seconds

Are those times as strings or time-values with a custom number-format. If
the latter multiply by (24*60*60)

Regards,
Peter T

"inungh" wrote in message
...
I have a spreadsheet which contains time information like follwoing
format

0h 15m 35s
7h 1m 5s

and I would like to convert in seconds,

Are there any functions or formula to do this?


Your help is great appreciated,



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Time in Seconds Only Chad Cameron[_2_] Excel Discussion (Misc queries) 2 May 6th 10 05:40 PM
How do I change a minutes and seconds as a 2400 time to seconds? NickBrown419 Excel Worksheet Functions 1 August 10th 08 09:12 PM
time in seconds Frank New Users to Excel 1 April 7th 08 12:06 PM
how do i add seconds (time)? eufemistic Excel Worksheet Functions 5 January 28th 06 06:29 PM
Convert "Time Interval" in "hours : minutes : seconds" to seconds Ianukotnorth New Users to Excel 7 May 8th 05 08:11 PM


All times are GMT +1. The time now is 01:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"