Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Changing Date from string to Date format

Dheeru28
8 - Asteroid

Hi All,

I have dates in my data in the following two formats: yyyy-mm-dd and dd/mm/yyyy. They are in the same column and data type is string.

 

I want to change both of these into dd-mm-yyyy format.

 

I tried using formula tool but that omits one of the above formats and gives null for those. DateTime tool is also not giving the required result.

 

How to do it in a simple way so that dates in both the above formats change to the required format and don't give null values?

3 REPLIES 3
JosephSerpis
17 - Castor
17 - Castor

Hi @Dheeru28 you will need to parse your dates twice given you have two formats. You could wrap this in a conditonal statement first testting for the format then parsing it. I have mocked up an approach which showcases one way to tackle this.

 

dates_27112023.JPG

Deano478
12 - Quasar

hey @Dheeru28 you could use this expression: 

IIF(Contains([Date], '/'),
    DateTimeFormat(DateTimeParse([Date], '%d/%m/%Y'), '%d-%m-%Y'),
    DateTimeFormat(DateTimeParse([Date], '%Y-%m-%d'), '%d-%m-%Y'))
Warmer
5 - Atom

I have dates in my data in the following two formats: yyyy-mm-dd and dd/mm/yyyy. If the formats yyyy-mm-dd and dd/mm/yyyy is the only formats , u just need the tool DateTime in Parse 。

 

Choose String to Date/Time format

 

捕获ssss.PNG

 

It will be done easily.

 

捕ddddd获.PNG

捕wwww获.PNG

Labels
Top Solution Authors