Extract Date and Time from a string

srrboarder

New Member
Joined
Nov 29, 2010
Messages
8
Hello,
I'm working with a data export that is throwing a time stamp entry into 1 cell. I need to break out the date and time into separate cells so that excel will recognize both as a date and a time. Can someone help build a formula that will separate the necessary data?

Assume my data starts in A1 (there will not be a set number of entries but all entries will be within column A).

Data in A1 looks as follows: Friday, June 24, 2011 at 4:04pm

I need "June 24, 2011" to go into its own column

I need "4:04 PM" to go into its own column --> Also, please note that the time stamp does not put a space between the numeric time and the "AM/PM" so the formula would need to place that space there instead.

Please keep in mind that the dates are for the entire year (so multiple months are represented and times may also contain 4 numeric digits instead of just 3 (ex.12:00).

Thanks for any help you are able to provide.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi, is A1 formatted as text?

Anyways here is the way to get ur date.
=LEFT(A1, FIND("at",A1) - 2)

for your time
=RIGHT(A1, LEN(A1) - FIND("at",A1) - 2)
 
Upvote 0
VoG,

Your formula for the time works brilliantly! Thanks!

I'm having some difficulty with the date formula though. Is there any way to get the result to end up being able to be formatted as a "short date" in excel? I have other formulas referencing these dates (which I've been putting in manually up to this point!).

For example, if you're able to run a "=weeknum" or "weekday" formula off the result in B1, that would be the ideal. Is this possible?

Let me know if I need to explain this better!

Thanks!
 
Upvote 0
Try this formula to extract the date

=REPLACE(LEFT(A1,FIND("at",A1)-2),1,FIND(",",A1)+1,"")+0

format any way you want......
 
Upvote 0
Barry,
I was able to use your "replace" formula for my date extraction. However, it works for every day except Saturdays. Any idea why? I tried to break down how the formula is referencing the characters within the cell and I'm not seeing why it won't recognize a Saturday's date. Very strange. I've copied an example below.

Saturday, June 25, 2011 at 8:08am

The return i get after using your formula is the "#Value" error.

I appreciate any help you can provide.

Thanks!
 
Upvote 0
D'oh!

My formula works by finding the "at" between the year and the time......but of course Saturday is the one day of the week which also contains "at".....you can amend formula slightly to search for "at " (with a space), i.e.

=REPLACE(LEFT(A1,FIND("at ",A1)-2),1,FIND(",",A1)+1,"")+0
 
Upvote 0
I sure everyone will have a slightly different format, this is typical of the formulas I would use

This should extract the date.
=VALUE(TRIM(LEFT(RIGHT(A1,7),5))&" "&RIGHT(A1,2))

This should extract the day
=VALUE(MID(A1,FIND(",",A1)+2,LEN(A1)-FIND(",",A1)-11))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,786
Members
452,942
Latest member
VijayNewtoExcel

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