Convert Date and Time Text to an Excel Date/Time Serial Number

wdgor

Board Regular
Joined
Jan 21, 2009
Messages
90
Office Version
  1. 365
Platform
  1. Windows
Any ideas on how I could convert this text string into a date/time serial number in Excel? Thanks for any assistance.

12:09:01AM Jun 18, 2022
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
If you have Power Query on board (Excel 2013 or higher, for Excel 2010 it can be installed as add-on).
Simply load the data to PQ and the conversion is done.
1655573306417.png


Book1
ABCDE
1when loaded to table
2Column1Column1
312:09:01 AM Jun 18, 202218/06/2022 0:09
4
Sheet1
 
Upvote 0
If it helps you have a time and a date and can convert them

Assume Cell A1 has your Date/Time as Text

1655574096113.png


This would result in

1655574123044.png
 
Upvote 0
This looks like a really elegant solution but I have never used power query. I have Excel 365 and power query does show up under the data tab. When I select it and try to use data sources in the current workbook, I get "We didn't find any data sources in this workbook". I originally tried to parse out the data table (see below) thinking that I might be able to do something with it - no luck. Perhaps I need to do some YouTube investigation on how to use power query.

1655574587671.png

TimeTime2Column3Column4Column5
12:08:53AM Jun 18, 202212:08:53AMJun18,
2022​
12:08:57AM Jun 18, 202212:08:57AMJun18,
2022​
12:09:01AM Jun 18, 202212:09:01AMJun18,
2022​
12:09:05AM Jun 18, 202212:09:05AMJun18,
2022​
12:09:09AM Jun 18, 202212:09:09AMJun18,
2022​
12:09:13AM Jun 18, 202212:09:13AMJun18,
2022​
12:09:17AM Jun 18, 202212:09:17AMJun18,
2022​
12:09:21AM Jun 18, 202212:09:21AMJun18,
2022​
12:09:25AM Jun 18, 202212:09:25AMJun18,
2022​
12:09:29AM Jun 18, 202212:09:29AMJun18,
2022​
12:09:33AM Jun 18, 202212:09:33AMJun18,
2022​
12:09:37AM Jun 18, 202212:09:37AMJun18,
2022​
 
Upvote 0
Coding4Fun - Looks like that might work but I have over 10,000 rows to convert. I took your formulas and put them in separate columns and Voila, the last column has most of what I need - brilliant! Thank you so much. Just one exception, the 12:08 is AM and not PM as the last column represents. That will be a problem in a calculation that goes over midnight.

12:08:53AM Jun 18, 202212:08:53AMJun 18, 2022
0.506168981​
44730​
6/18/22 12:08 53 PM​
 
Upvote 0
One example is almost always not enough. For the example you posted, we cannot tell if the time value has a leading zero for single hour time values nor can we tell if the day number has a leading zero for dates before the 10th of the month. If the time value always has a leading zero, then this formula will work whether the day value has a leading zero or not...
Excel Formula:
=0+MID(A1&" "&REPLACE(A1,9,0," "),12,LEN(A1)+1)
 
Upvote 0
Solution
Coding4Fun - Looks like that might work but I have over 10,000 rows to convert. I took your formulas and put them in separate columns and Voila, the last column has most of what I need - brilliant! Thank you so much. Just one exception, the 12:08 is AM and not PM as the last column represents. That will be a problem in a calculation that goes over midnight.

12:08:53AM Jun 18, 202212:08:53AMJun 18, 2022
0.506168981​
44730​
6/18/22 12:08 53 PM​
Perhaps

1655578470930.png

1655578479732.png
 
Upvote 0
Rick -
One example is almost always not enough. For the example you posted, we cannot tell if the time value has a leading zero for single hour time values nor can we tell if the day number has a leading zero for dates before the 10th of the month. If the time value always has a leading zero, then this formula will work whether the day value has a leading zero or not...
Excel Formula:
=0+MID(A1&" "&REPLACE(A1,9,0," "),12,LEN(A1)+1)
There is a leading zero on the time. This is a data extraction from a recording pulse oximeter and is usually done during sleeping hours which, obviously, can include hours before or after 10PM and early morning hours. In any case, I applied your formula to both times and got the expected result - thank you very much!! Some day I hope to become more expert in Excel but it is comforting to know that there are brilliant minds out there who are willing to assist. Thank you again.

12:08:57AM Jun 18, 20226/18/2022 12:08:57 AM
03:03:57AM Jun 18, 20226/18/2022 3:03:57 AM
 
Upvote 0
@wdgor - You are supposed to mark the message with the solution in it that you are going to use as the Answer, not your message saying ithat you have a solution.
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,824
Members
449,190
Latest member
rscraig11

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