Extract Date From Text using VBA

hsmith15

New Member
Joined
Jan 19, 2018
Messages
8
I export data from a sales reporting system to generate custom sales reports.

The date now is exported in the format "Thu Jan 18 22:23:12 UTC 2018".

Is there any way for me to extract the date in format of "mm/dd/yyyy" from this text?

Thanks!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I export data from a sales reporting system to generate custom sales reports.

The date now is exported in the format "Thu Jan 18 22:23:12 UTC 2018".

Is there any way for me to extract the date in format of "mm/dd/yyyy" from this text?
If your text uses leading zeroes for single digit day and hour numbers, then this might work for you (the formula is dependent on your computer's regional settings)...

=0+(MID(A1,5,5)&","&RIGHT(A1,5))

This formula returns the serial number for the date so you will have to use Cell Formatting to make it look like mm/dd/yyyy.
 
Upvote 0
Rick,

Thank you very much. I wasn't aware of this formula. The formula you wrote came back as 1/1/18 where the date in the code is 1/18/18.

However, changed it to =0+(MID(A1,5,5)&","&RIGHT(A1,5)). Changing the num_chars in the MID section to 7 instead of 5 came back with 1/18/18. Does this seem like the correct fix?

Thanks.
 
Upvote 0
Rick,

Thank you very much. I wasn't aware of this formula. The formula you wrote came back as 1/1/18 where the date in the code is 1/18/18.

However, changed it to =0+(MID(A1,5,5)&","&RIGHT(A1,5)). Changing the num_chars in the MID section to 7 instead of 5 came back with 1/18/18. Does this seem like the correct fix?
That second 5 (the one you underlined) was a typo on my part... I meant to type 6 (not 7).
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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