• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Extract Date From Text String

Nikesh Valji

New Member
Hello all,

I am trying to extract the date from the attached date string. Some of the entries are easy and I can use the "text to column" function. However I think some dates are as text and I am finding it difficult to carry this out for the entire data set. Ideally, I would like to extract the date in the following format: dd-mmm-yy.

Any help would be greatly appreciated.

Thanks,
Nik
 

Attachments

  • Date extract.xlsx
    732.5 KB · Views: 7
Thanks - I have tried that but it only works for some and others it gives a value error - please see attached.

Thanks,
Nik
 

Attachments

  • Date extract.xlsx
    938.9 KB · Views: 6
There's mismatch between what's being brought in and what you have set as your region.

How are you importing those dates into your workbook?

I'd recommend importing as text (using import wizard). Then performing text manipulation on it to transform it into dates. Otherwise you'll get mixed results like you got in your workbook.
 
@sureshsonti
It works for you, since your system date format is set to m/dd/yyyy format (as is mine). I suspect Op has it system date (region setting) set to dd/mm/yyyy format.

This causes dates such as 07/31/2018 to be considered invalid date format and imported as text. But dates such as 07/01/2018 will be interpreted as Jan 7, 2018 and imported as such. Hence, why OP's example worked up to 7/12/2018, but not after (as there's no 13th month).

To avoid this sort of mix-up, it is always advisable to either export dates in format required by client application, or in text format, and transform after it is imported to client system using text manipulation.
 
As your dates are padded with 0 you can use absolute references (4, 3)
=TEXT(IF(ISTEXT(A2),MID(A2,4,3)&REPLACE(A2,4,3,),TEXT(A2,"mm/dd/yy")),"dd-mmm-yy")
 
That they have a 0 before the numbers smaller than 10, like 01/07/2018 instead of 1/7/2018, so the date always has the same number of digits.
 
Last edited by a moderator:
Back
Top