Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Convert timespan d:hh:mm:ss to number

Hi,

I have a field that is imported from Siebel to CSV in the format d:hh:mm:ss.
I need to convert this back to seconds. I have tried changing the format of
the cells but this does not work.

Can anyone help?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Convert timespan d:hh:mm:ss to number

Assuming the date is text, try this UDF:

Function changeit(r As Range) As Long
Dim nv As Long
s = Split(r.Value, ":")
nv = 24# * 60# * 60# * s(0)
nv = nv + 60# * 60# * s(1)
nv = nv + 60# * s(2)
nv = nv + s(3)
changeit = nv
End Function

This can also be performed directly on the worksheet, without any VBA:

=LEFT(C4,1)*24*60*60 + MID(C4,3,2)*60*60+MID(C4,6,2)*60+RIGHT(C4,2)

--
Gary''s Student - gsnu200760


"Enigo" wrote:

Hi,

I have a field that is imported from Siebel to CSV in the format d:hh:mm:ss.
I need to convert this back to seconds. I have tried changing the format of
the cells but this does not work.

Can anyone help?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Convert timespan d:hh:mm:ss to number

It's probably text.
Suppose your data is in column A and the columns B:F are free.
DataText to columns, delimited, check Other and use the colon symbol
Now you should have days in A, hours in B, minutes in C and seconds in D. In E1:
=((A1*24+B1)*60+C1)*60+D1
This is seconds as a number. If you require seconds as real Excel time: in F1:
=E1/24/60/60, Format Custom as [s]


--
Kind regards,

Niek Otten
Microsoft MVP - Excel


"Enigo" wrote in message ...
| Hi,
|
| I have a field that is imported from Siebel to CSV in the format d:hh:mm:ss.
| I need to convert this back to seconds. I have tried changing the format of
| the cells but this does not work.
|
| Can anyone help?
|
| Thanks


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
convert number to % using only custom number format challenge Brotherharry Excel Discussion (Misc queries) 7 June 2nd 09 06:29 PM
Convert a number formatted as text to a number in a macro MACRE0[_5_] Excel Programming 2 October 22nd 05 02:51 AM
convert text-format number to number in excel 2000%3f Larry Excel Discussion (Misc queries) 1 July 29th 05 08:18 PM
not able to convert text, or graphic number to regular number in e knutsenk Excel Worksheet Functions 1 April 2nd 05 08:41 AM
convert decimal number to time : convert 1,59 (minutes, dec) to m agenda9533 Excel Discussion (Misc queries) 8 January 20th 05 10:24 PM


All times are GMT +1. The time now is 06:52 AM.

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"