How many times have you turned a a sting into a date in Alteryx? Learn a new trick to deal with custom date formats more efficiently in this blog!
Let’s say that you want to turn a string field into a date or datetime field. The field looks like this:
How do we turn it into a datetime field?
The most natural thing to do might be to use the DateTime tool. Unfortunately, our fields’s format does not correspond to any available datetime format available in the tool. Therefore, we will need to select “Custom” under “Select the format that matches the incoming string field” and type: yyyy-mm-ddThh:mm:ss
How to do deal with custom date formats in two steps:
However, if you are like me, you won’t enjoy having to type the exact date format. Luckily, there’s a short and sweet alternative solution! Here it is:
Use Formula Tool and type: Replace([date_time], ‘T’, ‘ ‘)
Drag in a Select Tool and change the field’s data type to datetime.
…and you’re good to go! You know how to turn a string into a date!
For a practical example of this trick, check out DavidP’s workflow here.