Date string

Status
Not open for further replies.

alexboe

New Member
Joined
Dec 22, 2017
Messages
4
Hi,

I'm trying to transform date string formatted like: Jan 1, 2017 6:01:12 AM PST

How do I transform those dates with a formula into a actual date as recognised by excel?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I'm sure there will be another, probably better way, but this seems to work.

Code:
=DATE(INT(MID(D2,FIND(" ",D2,FIND(" ",D2)+1)+1,4)),INT(MATCH(E2,{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"},0)),INT(MID(D2,FIND(" ",D2)+1,FIND(",",D2)-FIND(" ",D2)-1)))
 
Upvote 0
And another option.

Code:
=DATEVALUE(LEFT(D20,FIND(" ",D20,FIND(" ",D20,FIND(" ",D20)+1)+1)))
 
Upvote 0
And a couple more for fun.

Code:
=DATEVALUE(LEFT(D20,FIND(CHAR(1),SUBSTITUTE(D20," ",CHAR(1),3))))

VBA

Code:
Function ConvertDate(sDate As String) As Date
Dim AR() As String
AR = Split(sDate, " ")
ConvertDate = DateValue(AR(0) & " " & AR(1) & " " & AR(2))
End Function
 
Last edited:
Upvote 0
alexboe, Good afternoon.

You really have now a lot of very good options.

I will leave my modest contribution here as well.

If your dates are in a particular column, you can convert them in the same place and permanently using the function TEXT TO COLUMN..

Suppose they are at column A.

Select the cells with the dates.

Data menu -> Text to Column

Fixed with -> Next

Delete the column delimiters and leave only that is after the year 2017. --> Next

The first column of the DATA PREVIEW will be selected, then CLICK the DATE button by selecting MDY.

Click the second column of the DATA PREVIEW and click on the button "DO NOT IMPORT COLUMN (SKIP).

Now just hit FINISH..

All cells are now dates recognized by Excel without the part that you do not want.

It works for a column or for a individual cell too.

I hope it helps.
 
Upvote 0
If your dates are in a particular column, you can convert them in the same place and permanently using the function TEXT TO COLUMN..
Besides Text To Columns, you can also use Excel's Replace dialog box. Select the column with your date/time values in it, then press CTRL+H to bring up the Replace dialog box, type (or copy/paste) this into the "Find what" field...

????????????PST

Leave the "Replace with" field empty. Press the "Options>>" button and make sure there is no check mark in the "Match entire cell contents" checkbox, then click the "Replace All" button.
 
Last edited:
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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