General Discussions

Discuss any topics that are not product-specific here.

Date Format Change

jmc1
5 - Atom

I am trying to change the format of a Date field.  It is currently displayed as 2024-07-15.  I need it to display in my output as 07/15/2024.  I have tried using the various versions of the following formula, but the output data is not changing.  Any advise would be helpful.    DateTimeFormat(DateTimeParse([WORKED_DATE],"%Y-%m-%d"),"%m/%d/%Y")    

 

 
 

 

 

4 REPLIES 4
Paridhi_Agrawal
8 - Asteroid

Try this

CoG
13 - Pulsar

My guess is that you are using the formula above to change a Date Type field. This will not work because the date types must remain in the ISO 8601 format (YYYY-mm-dd) as you have observed. This is necessary to be able to perform date based calculations and operations (e.g. DateTimeAdd(), Sorting, etc.) in a consistent and repeatable way.

 

Best practice is to leave your columns as Date types (or convert them as early as possible) for the entirety of your workflow until the end, where you can change the field to a String type or add a new String column, at which point the code you have included above should convert the date into your desired String format for better readability in your output (unless of course you are outputting to another Typed data source like a SQL table).

 

Hope this helps and Happy Solving!

shancmiralles
10 - Fireball

hello @jmc1 

 

hope you are well

your date  2024-07-15 is the "official" date format in alteryx .. if you want this to be changed to  07/15/2024 then you have to use the "datetime" tool and do a " date/time format to string" and select the format MM/dd/yyyy .. if you need the date still in date data type ( for formula/computation reason) i suggested changing it before your output data tool. 

TUSHAR050392
9 - Comet

You can use the DateTime tool and select the format to convert as Date/Time format to string. This can help you convert the date into your required format by selecting the format for new column as MM/dd/yyyy.

Labels