Converting Dates

tobermory

New Member
Joined
Jun 4, 2012
Messages
46
Hello Ladies and Gentlemen,

I have a column of dates, that I want in UK date format (DD/MM/YYYY)

Occasionally, the data I receive the dates are muddled up, some are in DD/M/YYYY and some are in MM/DD/YYYY

The ones with a star are incorrect, and come in 'General' format.

[TABLE="width: 114"]
<colgroup><col></colgroup><tbody>[TR]
[TD]Date
[/TD]
[/TR]
[TR]
[TD="align: right"]03/06/2017[/TD]
[/TR]
[TR]
[TD]07/18/2017*
[/TD]
[/TR]
[TR]
[TD]03/16/2018*
[/TD]
[/TR]
[TR]
[TD]02/26/2018*
[/TD]
[/TR]
[TR]
[TD="align: right"]03/10/2018[/TD]
[/TR]
[TR]
[TD="align: right"]04/11/2018[/TD]
[/TR]
[TR]
[TD]05/13/2017*

[/TD]
[/TR]
</tbody>[/TABLE]
I CAN already convert these, by selecting MDY in the 'Text To Columns' Wizard.

However, occasionally, my columns are dates that ARE already in the correct format. So if I run the wizard, it converts some from DD/MM/YYYY to MM/DD/YYYY.

Would there be some wizardy, where it looks at a column, and if the dates are all already in DD/MM/YYYY, don't do anything, but if there are some in MM/DD/YYYY, then convert these to DD/MM/YYYY?

Thank you.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
However, occasionally, my columns are dates that ARE already in the correct format.
I don't think that is necessarily true. If all the dates came from the same source, then all of them had their month/day positions reversed from what you want. Just because Excel made some of them actual dates does not mean they are the correct dates. If the day number is 12 or less, then Excel will make that date into a "real" date, but it will not be the corrected date. You should check some of those "real dates" back to the source to see if the month/day order actually matches what you think they should have converted to.
 
Upvote 0
I think exactly the same as Rick suspects and if he is correct then the formula below should correct it (I am sure Rick will give a VBA solution once you confirm back).

=IFERROR(IF(ISNUMBER(A1),VALUE(TEXT(A1,"mm/dd/yyyy")),DATE(RIGHT(A1,4),LEFT(A1,FIND("/",A1)-1),MID(A1,FIND("/",A1)+1,2))),DATE(RIGHT(A1,4),LEFT(A1,FIND("/",A1)-1),MID(A1,FIND("/",A1)+1,1)))
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,177
Members
452,615
Latest member
bogeys2birdies

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