Thursday, 26 November 2020

How to convert a text format to date format in excel - Tableau Way

 For example if you have a date like:


July 10, 2020 : Normally in tableau

How to convert ( Logic)

1. Month

 Extract the characters till you get a space and convert those characters to the month number

=MONTH(DATEVALUE(LEFT(A2,FIND(" ",A2))&"1"))

2. Day

Extract the characters between space and comma. Basically this is the way how we extract string between two characters


=MID(A2, FIND(" ",A2)+1, FIND(",", A2, FIND(" ", A2)+1)-FIND(" ",A2)-1)

3. Year

Extract the rightmost four characters

=RIGHT(A2,4)

4. Convert everything into date format which is given by

Date( Year, Month,Day)

=DATE(RIGHT(A2,4),MONTH(DATEVALUE(LEFT(A2,FIND(" ",A2))&"1")),MID(A2, FIND(" ",A2)+1, FIND(",", A2, FIND(" ", A2)+1)-FIND(" ",A2)-1))



No comments:

Post a Comment