1.

Solve : MS Excel time format question?

Answer»

Hi All,

I am using the software Benchlink Data Logger 3 to take some measurements (electrical current) and then exporting the data into a .csv file. From there I have an excel template that I use to graph the "raw" data. The template I have was designed for the Benchlink Data Logger 1. In the template for the older version the "time stamp" was exported as follows:

0.018
0.102
0.202
0.302
0.402
0.502
etc...
(Time as a decimal I think)

The formatting on the cell is Number/General. The template has formulas that use these numbers (time) to show time on a graph.

The newer Benchlink Data Logger 3 exports time as follows:

00:00:00:00:000
00:00:00:00:219
00:00:00:00:323
00:00:00:00:427
00:00:00:00:530
00:00:00:00:635
00:00:00:00:738
00:00:00:00:840
etc...
(looks like straight time in day:hour:minute:second:milliseconds)

The formatting in this cell is also Number/General.

No matter what I have tried I cannot get excel to take the time format 00:00:00:00:000 and convert it to a decimal. (which is what I think I need to do) and the Benchlink Data logger software will not export the time as a decimal like the earlier version did.

Any help would be great. If you need the actual formulas or .csv's and/or template please let me know let me know and I can e-mail them to you as an example of what it's doing.

Thanks in advance.Hello Chuck

I don't think Excel can format cells beyond hh:mm:ss.decimals so the amount of pairs of zeros you have there is CONFUSING it.

I have tried pasting one of those later formats you typed into excel and it's not recognised as a number format at all (despite what you choose in Format, Cells). You can tell this as it left aligns the data when it's pasted.

I've just been having a fiddle and I think we should be able to truncate your data down using a combination of =RIGHT and also TRIM and CLEAN funcitons to be able to achieve what you need and remove the excess pairs of zeros.

However...so that I can understand your data, is the first set of data you posted the same as the second set? Or are you expecting the second set to display decimals 0.000, 0.219, 0.323 (for the first three instances)?It's called Parse

Data---Text to Columns
Convert Text to Column Wizard; Step 1 -- Delimited
Convert Text to Column Wizard; Step 2 -- Delimited; Other [:]
Convert Text to Column Wizard; Step 3 -- Finished

A B C D E
00 00 00 00 000
00 00 00 00 219
00 00 00 00 323
00 00 00 00 427
00 00 00 00 530
00 00 00 00 635
00 00 00 00 738
00 00 00 00 840

Delete columns A thru D.

Computer_Commando, I believe we need to know whether ChuckSteak ever has data other than 0s in the day:hour:minute:second columns. If so and if those data elements are needed, then parsing into columns and deleting the four columns representing day:hour:minute:second would not work.

Quote

No matter what I have tried I cannot get excel to take the time format 00:00:00:00:000 and convert it to a decimal.
Seems pretty obvious to me Excel will not convert 00:00:00:00:219 to a decimal. Exacfly what part of that date/time sequence do you want converted to a decimal? If you were just working with hours and minutes, then I believe a formula can be used to convert the minutes to a decimal portion of an hour. For example, 1 hour 30 minutes could be converted to 1.5 hours. Quote from: LottieB on August 03, 2010, 03:18:47 PM
Hello Chuck

I don't think Excel can format cells beyond hh:mm:ss.decimals so the amount of pairs of zeros you have there is confusing it.

I have tried pasting one of those later formats you typed into excel and it's not recognised as a number format at all (despite what you choose in Format, Cells). You can tell this as it left aligns the data when it's pasted.

I've just been having a fiddle and I think we should be able to truncate your data down using a combination of =RIGHT and also TRIM and CLEAN funcitons to be able to achieve what you need and remove the excess pairs of zeros.

However...so that I can understand your data, is the first set of data you posted the same as the second set? Or are you expecting the second set to display decimals 0.000, 0.219, 0.323 (for the first three instances)?

Thanks for the help.

No, the first set of data is not the same as the second set. I copied data from an earlier/older excel file that the data was imported using the original Benchlink Data Logger 1 that puts the time in decimal format itself. The second set of data is from the newer Benchlink Data Logger 3 that uses the day:hour:etc... format.Quote from: Computer_Commando on August 03, 2010, 03:34:18 PM
It's called Parse

Data---Text to Columns
Convert Text to Column Wizard; Step 1 -- Delimited
Convert Text to Column Wizard; Step 2 -- Delimited; Other [:]
Convert Text to Column Wizard; Step 3 -- Finished

A B C D E
00 00 00 00 000
00 00 00 00 219
00 00 00 00 323
00 00 00 00 427
00 00 00 00 530
00 00 00 00 635
00 00 00 00 738
00 00 00 00 840

Delete columns A thru D.



Unfortunately I don't think this will work because, as mentioned by soybean, my data is generally goes for around 9 minutes long and sometimes into the hours as well. Never days though.

Thanks for looking at this. I am no EXPERT in excel but it's one of those things that I know we "should" be able to do, but just can't for some reason.Quote from: soybean on August 04, 2010, 07:09:27 AM
Computer_Commando, I believe we need to know whether ChuckSteak ever has data other than 0s in the day:hour:minute:second columns. If so and if those data elements are needed, then parsing into columns and deleting the four columns representing day:hour:minute:second would not work.
Seems pretty obvious to me Excel will not convert 00:00:00:00:219 to a decimal. Exacfly what part of that date/time sequence do you want converted to a decimal? If you were just working with hours and minutes, then I believe a formula can be used to convert the minutes to a decimal portion of an hour. For example, 1 hour 30 minutes could be converted to 1.5 hours.

My test generally runs about 9 minutes. At the rate the data acquisition logger is scanning this means about 5500 scans in that 9 minutes. So that's 5500 cells worth of data that needs to be converted. Sometimes I run a longer test, but SLOW down the scan speed of the data acquisition logger. But for time I run tests ranging from 9 minutes to 7 hours.Is this what you need?

http://tinypic.com?ref=200u22s" target="_blank">http://i35.tinypic.com/200u22s.jpg" border="0" alt="Image and video hosting by TinyPic">[/url]Quote from: LottieB on August 04, 2010, 11:20:25 AM
Is this what you need?

<a href="http://tinypic.com?ref=200u22s" target="_blank"><img src="http://i35.tinypic.com/200u22s.jpg" border="0" alt="Image and video hosting by TinyPic">[/url]

I tried that after seeing your first reply. Unfortuantely it doesn't get me what I need. I need the time to be in decimal format. If we can "trim" off the extra data then convert it to a decimal I would be golden. In short if the end result is 00:xx:xxx it still doesn't work for me.

Thanks again for the help.Hi Chuck

I think you need to give me more information as to how the last 3 digits relate to time.

For example, I was assuming the .219 bit (in A3 in my example) is a fraction of a second, i.e. 219/1000 of a second. I take it this isn't so?Quote from: LottieB on August 04, 2010, 01:39:27 PM
...I think you need to give me more information as to how the last 3 digits relate to time.
For example, I was assuming the .219 bit (in A3 in my example) is a fraction of a second, i.e. 219/1000 of a second. I take it this isn't so?
He said is was so: "...looks like straight time in day:hour:minute:second:milliseconds..."
He needs the entire cell converted to seconds. Back to parsing & then multiplying:
(A * 86400) + (B * 3600) + (C * 60) +D + E = Elapsed Time (Seconds)Quote from: Computer_Commando on August 04, 2010, 02:06:46 PM
He said is was so: "...looks like straight time in day:hour:minute:second:milliseconds..."
He needs the entire cell converted to seconds. Back to parsing & then multiplying:
(A * 86400) + (B * 3600) + (C * 60) +D + E = Elapsed Time (Seconds)

Exactly.
And if you look at the pic I posted, the last part of the number is a decimal to 1000. And one millisecond is 1/1000th of a second is it not?
The 00:00 part is separated by COLONS and if you create a custom number format to interpret as a time value then Excel will read the whole thing as time - provided the initial exported data has had one set of 00S removed (which is why parsing doesn't work as it removes the colons and I'm not entirely sure the remaining data wouldn't still be being interpreted at text, so a VALUE function will still be needed along with something to substitute the final set of colons with a DP).

Well that's the way I'm seeing it at the moment ...I shall not be defeated OK Ignore my last post

I hadn't realised Chuck wanted the other time parts converted to a number too, I was thinking it was just the fractional part.

Is this what you want Chuck?



In which case use Data Text to Columns (the ole parsing) to a general format and then do a formula to get your time conversion.

Quote from: Computer_Commando on August 04, 2010, 02:06:46 PM
He said is was so: "...looks like straight time in day:hour:minute:second:milliseconds..."
He needs the entire cell converted to seconds. Back to parsing & then multiplying:
(A * 86400) + (B * 3600) + (C * 60) +D + E = Elapsed Time (Seconds)
I forgot to divide "E" by 1000.
(A * 86400) + (B * 3600) + (C * 60) +D + (E/1000) = Elapsed Time (Seconds)

Now, we're in agreement, except you need to add hours, too. He said "...my data is generally goes for around 9 minutes long and sometimes into the hours as well. Never days though..." Can't hurt to add them all, since days will be 0.a VBA Macro can do the trick.


Alt-F11. Choose Insert->Module from the Visual Basic Editor that appears.

Paste the following into that module:

Code: [Select]Option Explicit



Public Function BenchLink_Format(ByVal BenchLinkData, Optional ByVal Separator As String = ":") As Date
'00:00:00:00:219
Static flInit As Boolean, Stepamounts() As Double
Dim SplitParts() As String

If Not flInit Then
flInit = True
ReDim Stepamounts(0 To 4)
Stepamounts(0) = 60# * 60# * 24#
Stepamounts(1) = 60# * 60#
Stepamounts(2) = 60
Stepamounts(3) = 1
Stepamounts(4) = 0.001
End If
Dim ReturnValue As Variant, I As Integer
ReturnValue = 0
SplitParts = Split(BenchLinkData, Separator)
For I = 0 To UBound(Stepamounts)
ReturnValue = ReturnValue + CDec(Val(SplitParts(I)) * Stepamounts(I))
Next I


BenchLink_Format = ReturnValue




End Function


now use it in your spreadsheet as follows:

Code: [Select]=BenchLink_Format(Value)

in the test spreadsheet I had column A contain the data you provided. Column B was just =BenchLink_Format(A1) set to fill downward. The resulting spreadsheet looks something like this:

Code: [Select]
00:00:00:00:000 0
00:00:00:00:219 0.219
00:00:00:00:323 0.323
00:00:00:00:427 0.427
00:00:00:00:530 0.53
00:00:00:00:635 0.635
00:00:00:00:738 0.738
00:00:00:00:840 0.84

The result is represented in seconds.


Discussion

No Comment Found