Date format of dates stored as text

Deutz

Board Regular
Joined
Nov 30, 2009
Messages
191
Office Version
  1. 365
Platform
  1. Windows
Does anyone know how to return the date format of dates stored as text?

I have a column of dates delimited by commas which I split into individual strings. I then want to determine the date format for each string.

Examples of desired results:

If cell contains "301009" ---------------- then return dmy
If cell contains "12/05/09" -------------- then return dd/mm/yy
If cell contains "12/05/2009" ------------ then return dd/mm/yyyy
If cell contains "05/21/09" -------------- then return mm/dd/yy
If cell contains "Mon-10-2008" ---------- then return ddd-m-yyyy
If cell contains "12 November 2009" ----- then return dd mmmm yyyy
<TABLE id=table1 cellSpacing=0 cellPadding=2 width="50%" border=0><TBODY><TR vAlign=top><TD align=left></TD><TD align=left></TD></TR><TR vAlign=top><TD align=left>Thanks for you assistance

Michael
</TD><TD align=left></TD></TR><TR vAlign=top><TD align=left></TD><TD align=left></TD></TR><TR vAlign=top><TD align=left></TD><TD align=left></TD></TR></TBODY></TABLE>
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
1) Strings stored as text don't have a "date format". They are strings. It's up to the human mind to interpret what the strings mean.

Even in your example above you contradict "simple" logic with examples two and four...those two text strings are identical in layout, but you indicate they should return different "date formats".

Discerning between those formats is easy for humans, but not to a formula or macro. If a text string says 5/3/09 and it's stored as text, a human has to determine if that's May3rd or March5th.

2) You can convert most of those text strings INTO actual dates with a TEXT TO COLUMNS trick, but as you've already noted, they aren't consistent:

Excel Workbook
AB
1BeforeAfter
2
330100910/30/2009
412/05/095/12/2009
512/05/20095/12/2009
605/21/095/21/2009
7Mon-10-2008Mon-10-2008
812 November 200912-Nov-09
Sheet3


Steps:
a) Highlight column of values
b) Select Data > Text To Columns > Delimited > Next > Next
c) Select Date: in the upper right corner "Column Data Format" and select DMY
d) Click OK
 
Upvote 0
Thanks for the reply.

I see what you mean about interpreting strings different ways and the limits of what Excel can do in that respect.

For those strings that can be converted into dates, how would I then flag via VBA or formula what date format they are in?
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,141
Members
449,066
Latest member
Andyg666

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