How to fix incorrect TIMEVALUE() tiem format?

didj

Board Regular
Joined
Feb 7, 2008
Messages
50
Hi all, I have a column of time data imported from csv which is formatted as general. eg: 02:35 = 2 minutes, 35 seconds. This data is not time of day, but runtime since start of data recording. I want to convert all values to absolute seconds. Typically I use the *86400 method to do this.

The problem is that when using the TIMEVALUE() function, it appears to recognise the data as hh:mm. Therefore, to convert to an integer I must multiply by 86400/60 = 1440, but as soon as the datafile goes past 24 min, it recognises this instead as 24 hr and then resets back to zero.

I've been trying

runTime = ActiveCell.Value
runTime = Format(runTime, "mm:ss")

but to no avail since this still returns hours/mins instead of mins/sec.

Can anyone suggest a workaround?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
have you tried [h]:mm:ss as cell format

I don't recognise 24 minutes as an issue, but 24 hours can cause a problem if the format isn't set right
 
Upvote 0
Hi mole999, even if the time values are first formatted to "[h]:mm:ss" and then the timevalue() function is used, it recognises the minute values as hours. Therefore, converting with the timevalue() function and multiplying by 86400, a value of 24:06 (ie: 24 mins, 6 seconds) for example, will return 360 ie: 6 minutes past midnight.

I just discovered that if I manually enter "00:" before the value of 24:06, then I get the right number which is 1446 seconds. Seems like this will have to be the workaround. Add 00: at the start of every cell. Seems rather clunky though, and certainly I will write to the manufacturers and tell them to lift their game (just export the file with time format [h]:mm:ss).

Now what is the most efficient way to add "00:" at the start of a string?
 
Upvote 0

Forum statistics

Threads
1,215,330
Messages
6,124,308
Members
449,151
Latest member
JOOJ

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top