Alteryx Designer Desktop Discussions

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

Date Change

kpontarollo
8 - Asteroid

Hi! I need help finding a way to change the date format 1/1/2022 to 01/01/2022. Can anyone provide a solution

7 REPLIES 7
atcodedog05
22 - Nova
22 - Nova

Hi @kpontarollo 

 

This might look tricky here is a way to tackle it. 

 

1. Use datetimeparse() function to convert non-Alteryx date format to Alteryx dateformat. How datetimeparse work is you would need to give the format of the input date (DD/MM/YYYY) and it will convert it to Alteryx date (YYYY-MM-DD)

2. Once its converted to Alteryx date format we can use datetimeformat() to convert it back to the required format (DD/MM/YYYY)

 

Here is the documentation page of datetime functions go through it and you would be able to build these functions in no time https://help.alteryx.com/20214/designer/datetime-functions 

 

The hack here is when Alteryx converts it to the required dateformat it adds zero 🙂 and will output as 01/01/2022 

 

atcodedog05_0-1648835159185.png

 

Once you have figured out the steps you can nest them into a single formula.

 

Hope this helps : )

Luke_C
17 - Castor

Hi @kpontarollo 

 

You can use the datetime functions:

 

First, parse into an alteryx supported date (yyyy-mm-dd), then, format back to your desired format. This assume you provided m/d/yyyy. Switch the %m and %d identifiers if your date is d/m/yyyy. 

 

https://help.alteryx.com/20214/designer/datetime-functions

 

Luke_C_0-1648835322022.png

 

 

kpontarollo
8 - Asteroid

Thank you both so much, both have worked!

kpontarollo
8 - Asteroid

Hi! This worked great. Do you happen to have a fix for a problem that is one step more than this? 

 

I need to make the date: 4/07/2021 5:00 to 04/07/2021 05:00:00?

 

Let me know! Thank you!

DataNath
17 - Castor

@kpontarollo I have assumed that this is DD/MM/YYYY. If so, you can use:

 

Datetimeformat(DateTimeParse([Input],"%d/%m/%Y %H:%M"), "%d/%m/%Y %H:%M:%S")

 

DataNath_0-1652972880769.png

 

If it's MM/DD/YYYY, use:

 

Datetimeformat(DateTimeParse([Input],"%m/%d/%Y %H:%M"), "%m/%d/%Y %H:%M:%S")

 

DataNath_1-1652972924047.png

 

 

grazitti_sapna
17 - Castor

@kpontarollo , try this 

grazitti_sapna_0-1652973013095.png

 

Thanks!

Sapna Gupta
kpontarollo
8 - Asteroid

Thanks!

 

Labels