Convert text to time

logstarter

New Member
Joined
Apr 14, 2017
Messages
39
Hi,

I have a column of time showing like "01-JAN-19 03:23:22.120000 AM", I would like to ask how I could convert this text to time.

Thank you for your help.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
As long as it is a Value and not a String you could format the cells. Or use =TIME(HOUR(A1),MINUTE(A1),SECOND(A1)) to extract the time (again formatting the cells as this will default to a decimal number)
 
Upvote 0
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    DT = Table.TransformColumnTypes(Source,{{"Column1", type datetime}}),
    T = Table.TransformColumnTypes(DT,{{"Column1", type time}})
in
    T
Column1Column1
01-JAN-19 03:23:22.120000 AM03:23:22
01-JAN-19 03:23:22.120000 PM15:23:22
 
Upvote 0
As long as it is a Value and not a String you could format the cells. Or use =TIME(HOUR(A1),MINUTE(A1),SECOND(A1)) to extract the time (again formatting the cells as this will default to a decimal number)

but since the time is displayed in AM/PM format, how could I extract the value in the HOUR(A1) function?

Thank you.
 
Upvote 0
i am now using the following formula to solve it.. see if there is a better solution to replace it.

=if(right(a1,2)="AM", time(mid(a1,11,2), mid(a1,14,2), mid(a1,17,2)), time(mid(a1,11,2)+12, mid(a1,14,2), mid(a1,17,2)))
 
Upvote 0

Forum statistics

Threads
1,214,432
Messages
6,119,468
Members
448,900
Latest member
Fairooza

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