Converting Poorly Entered Time String into Time Value

cboyle

New Member
Joined
Jul 10, 2015
Messages
4
I have a dataset of times entered (incorrectly) in the format "10:32am" that I need to convert to sortable, graph-able time values. The best I've come up with so far is manually breaking the string apart and building it back together as the correct format, but it's not registering as a time value yet.

=LEFT(A1, LEN(A1) - 2) & " " & UPPER(RIGHT(A1, 2))

Any help would be much appreciated! Thanks in advance.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
The inclusion of the text value is the thing that's stopping you.
You might need to approach it with an if statement to examine whether the last two characters are PM, and add 0.5 to the value if it is.
 
Upvote 0
Try
=SUBSTITUTE(A1, "a", " a")+0
or
=REPLACE(A1, LEN(A1)-1, 0, " ")+0

The +0 changes the string into a number (time).
The cell then has to be converted to one of the time Number Formats.
 
Upvote 0
To add to that, =Left(A1,5) will return the value you desire, BUT it will always report AM.
So...
=IF(UPPER(RIGHT(A1,2)="PM"),LEFT(A1,5)+0.5,LEFT(A1,5))
Format as Time and you're good to go.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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