11 Replies Latest reply on May 30, 2017 8:39 AM by Glenn Kuly

# String to Date

Hi,

I am working in Tableau 10.1. I am trying to convert a string to a date. Below is the formula used. It is returning "null". Attached is the packaged workbook.

DATE(LEFT[DATE],3)+RIGHT([DATE],4))

Thanks.

• ###### 1. Re: String to Date

Hi Renu,

Find my approach as reference below and stored in attached workbook version 9.3 located in the original thread.

1.  find 20: find([Date],"20")

2.  month: mid([Date],1,[find 20]-1)

3. month notation:

if [month]="January" then 1

elseif [month]="February" then 2

elseif [month]="Marc" then 3

elseif [month]="April" then 4

elseif [month]="May" then 5

elseif [month]="June" then 6

elseif [month]="July" then 7

elseif [month]="August" then 8

elseif [month]="September" then 9

elseif [month]="October" then 10

elseif [month]="November" then 11

elseif [month]="December" then 12

END

4. year: right([Date],4)

5. date: date(str([year])+"-"+str([Month notation])+"-1")

Regards,

Norbert

• ###### 2. Re: String to Date

Hi Renu, try

DATEPARSE("MMM,yyyy", LEFT([Date],3) + ", " + RIGHT([Date],4))

To use the new date field in your chart, use Month (i.e. May 2015) and set the field to discrete.

-- Glenn

PS: I just noticed how you are sorting the dates in your chart; to do this with the calculated field shown above, arrange the pills as shown below:

• ###### 3. Re: String to Date

Hi Glenn,

Checked that one. What am I missing?

Regards,

Norbert

• ###### 4. Re: String to Date

Thank you.

• ###### 5. Re: String to Date

Thank you.

• ###### 6. Re: String to Date

Hi Renu,

You are welcome. Happy to help out.

Thanks for the "Badge".

Have  a nice one.

Regards,

Norbert

• ###### 7. Re: String to Date

Hi, Renu

try

DATE(RIGHT([Date],4) +"-" + LEFT([Date],3) + "-" + "01")

ZZ

• ###### 8. Re: String to Date

Weird, Norbert, the field looks identical to the one I used (i compared them character for character).

Do you get the same result if you take the field off of the Rows shelf then drop it back in?

-- Glenn

• ###### 9. Re: String to Date

I did try that one but I am getting null. I copied and pasted your formula into my file. I also entered it but still got "null".

Thx

• ###### 10. Re: String to Date

Hi Glenn,

Thanks for coming back to me. Could you share your workbook .

Upfront thanks a TON.

Regards,

Norbert

• ###### 11. Re: String to Date

Attached

-- Glenn