I need a formula to convert text into a date format.

maxim642

Board Regular
Joined
Feb 4, 2021
Messages
91
Office Version
  1. 365
Platform
  1. MacOS
Below is an example of my date format (UK).

22/01/2021 2:46:39 PM
6/05/2021 12:05:51 PM

In the adjacent cells, I would like to see 22/01/21 & 06/05/21, respectively. Thanks.

I tried using the LEFT formula, but wasn't sure how to format it as a date within that formula.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
but wasn't sure how to format it as a date within that formula.
=LEFT(A1,10)+0 then format the cell as date.

Note that this assumes dd/mm/yyyy regional system settings. With other settings you will get errors or wrong dates.
 
Upvote 0
Solution
Are those values entered as Text or Date/Time?

If you aren't sure, try using the ISNUMBER function on them, i.e.
Excel Formula:
=ISNUMBER(A1)

If it returns TRUE, it is a valid date/time entry.
If it returns FALSE, it is a text entry.

Jason's formula will work on text entries only.

If it is a Date/Time entry, you can simply use:
Excel Formula:
=INT(A1)
and choose your desired date format.
 
Upvote 0
Are those values entered as Text or Date/Time?

If you aren't sure, try using the ISNUMBER function on them, i.e.
Excel Formula:
=ISNUMBER(A1)

If it returns TRUE, it is a valid date/time entry.
If it returns FALSE, it is a text entry.

Jason's formula will work on text entries only.

If it is a Date/Time entry, you can simply use:
Excel Formula:
=INT(A1)
and choose your desired date format.
Cheers, Joe. I checked using your suggestion, and it did indeed return FALSE.
 
Upvote 0
Cheers, Joe. I checked using your suggestion, and it did indeed return FALSE.
OK, then Jason's formula is the way to go!

Note the reason why that works is because dates and times are actually stored in Excel as numbers, specifically the number of days since 1/0/1900 (so time is just a fraction of a day).
(That is why if you enter a date in any cell, and change the format to "General", you see a large number like 44000).

My reply addresses if you had a valid date/time entry, and wanted just the date portion.
We can use the INT function to take just the integer portion and drop the decimal (which is the time portion of that entry).
 
Upvote 0
@Joe4
Sometimes you can see the difference from the example. If you look at the second date the format is unconventional, suggesting that it is either text from an external source or a very specific custom format.

While not impossible, in my view it is extremely unlikely that anyone with the knowledge to set that as a custom format with a proper numeric date would need to come to the forum to ask how to separate the date and time.
 
Upvote 0
Sometimes you can see the difference from the example. If you look at the second date the format is unconventional, suggesting that it is either text from an external source or a very specific custom format.
True, though a format that starts like "d/mm/yyyy..." would return that.

While not impossible, in my view it is extremely unlikely that anyone with the knowledge to set that as a custom format with a proper numeric date would need to come to the forum to ask how to separate the date and time.
You would think so, but I have actually seen that question asked in the past.

I usually try not to assume anything!;)

Note that my original reply was not a refute of your original reply. I had originally just asked the question about the format, and amended it after I posted my reply and saw that you had submitted a reply while I was working on it. So I amended my original post to clarify the differences.
 
Upvote 0
Note that my original reply was not a refute of your original reply.
I didn't think that it was, Joe. My apologies if that is how my response came across. I know I make mistakes with my suggestions at times, we all have bad days and I would rather somebody challenge what I've said than let an error slip through and cause problems for those we're trying to help.
True, though a format that starts like "d/mm/yyyy..." would return that.
This was what I was referring to by a 'very specific custom format'. Maybe it is variable with different regional settings, but none of the native formats with UK settings mix a single digit day with a double digit month. It would have to be set up as a custom format by the user. With just the date, I would say that it is nothing elaborate, but with the time format, I've seen experienced users that don't know how to set the AM/PM part correctly.
 
Upvote 0
You are correct that based on the samples they posted, that it is probably more than likely a text entry. Truth be told, I didn't notice that "strange" format at first glance until you mentioned it.
I have seen people make typos in samples/examples many times, so you cannot always trust the format of the samples they posted, but this seemed to be a pasted image, so that probably is unlikely too.
So the assumptions you made appeared to be "more than likely correct" in this instance.

In any event, I also often like to use these type of questions as teaching mechanisms as well, as many people (especially noobies) don't realize that Excel actually stores dates/times as numbers.
So it can be an educational opportunity too! It might help them at some point down the road.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,269
Members
449,075
Latest member
staticfluids

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