Transform Text:2015/01/01 01:03:15 PM EST INTO DATE "01/01/2015"

yomero

Active Member
Joined
May 14, 2008
Messages
257
Hi,

I have to clean up a table.
The records were imported as text and are showing in 2 wasy:
- 42238
- 2015/01/01 01:03:15 PM EST

how can I convert them to a proper date column?
- DD/MM/YYY

Thanks!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Just entered 42238 in a cell, then changed the cell format to a date, which returned the date 22/08/2015
the 42238 is the serial number of the date since 1 Jan 1990, so 42239 is the 23/08/2015

as for the second one with the time, I'm not entirely sure on your options.
 
Upvote 0
Depending on the structure of your date/time values, there are a few ways to do this.
If the dates will always be 10 digits, you could simply extract 10 characters from the left: Left(yourvalue,10). I presume #'s will not be part of your date.

If not, you need to determine the length of the entire date (remember for this suggestion the date would sometimes be 01/01/2015 and sometimes 1/1/2015 or even 1/1/15 [not good]). So from 26 (2015/01/01 01:03:15 PM EST) you subtract 16 (the " 01:03:15 PM EST" portion), thus running the function: Left(Len(yourDate)-16).

If you want a format that differs from the value you have, or different from your system settings
(e.g. dd/mm/yyyy vs yyyy,mm/dd) you'll have to wrap the example within the Format function.
Maybe as: Format(Left(Len(yourDate)-16),"mm/dd/yyyy")

For the date serial numbers, Format(42238, "dd/mm/yyyy") will return 22/08/2015 as noted by cooper645
 
Upvote 0

Forum statistics

Threads
1,221,846
Messages
6,162,378
Members
451,760
Latest member
samue Thon Ajaladin

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