PC Review


Reply
Thread Tools Rate Thread

Convert timespan d:hh:mm:ss to number

 
 
Enigo
Guest
Posts: n/a
 
      5th Dec 2007
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 With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      5th Dec 2007
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

 
Reply With Quote
 
Niek Otten
Guest
Posts: n/a
 
      5th Dec 2007
It's probably text.
Suppose your data is in column A and the columns B:F are free.
Data>Text 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" <(E-Mail Removed)> wrote in message news:91F288F8-07AC-4236-9659-(E-Mail Removed)...
| 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert this timespan YXQ Microsoft VB .NET 2 19th Oct 2008 07:38 PM
How do I convert a DateTime table column to a TimeSpan or DayOfWeek ? Harry Haller Microsoft ASP .NET 0 21st Jul 2005 12:35 PM
convert timespan to time/datetime...? =?Utf-8?B?VmluYXk=?= Microsoft Dot NET Compact Framework 3 4th May 2005 09:32 AM
convert decimal number to time : convert 1,59 (minutes, dec) to m =?Utf-8?B?YWdlbmRhOTUzMw==?= Microsoft Excel Misc 8 20th Jan 2005 10:24 PM
command excel macros to convert a list 5 number number combinati. =?Utf-8?B?ZXhjYWxpYnVy?= Microsoft Access Macros 0 7th Dec 2004 04:55 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:21 AM.