Alteryx Designer Desktop Discussions

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

Date Time Add

sabidor829
7 - Meteor

Is there a way to remove the hours, minutes and seconds from this formula?  Also is there a way to arrange it so that it appears in the MM:DD:YYYY format? 

 

Please see the attached picture for reference. Thanks. 

 

 

 

7 REPLIES 7
Thableaus
17 - Castor
17 - Castor

Hi @sabidor829 

 

You can use ToDate() to remove the hours.

 

If you want to parse to MM:DD:YYYY format, you can use the DateTimeFormat function


DateTimeFormat([Date], "%m:%d%Y")


Cheers,

AliAS2020
8 - Asteroid

@sabidor829 

 

If you change the Data type to Date format the output will be only the date, if you change it to DateTime  the output will be DateTime format, since you using Data type as V_String then the output will include the time as well.

To re-format the DateTime you can use the DateTime tool or better you can use the DateTimeFormat() function in the formula tool like the attached pic.

 

Please check the DateTime functions to learn about all the available specifiers.

 

FormulasFormulasResultsResults

 

Cheers

 

AliAS

 

sabidor829
7 - Meteor

So I was able to remove the hours but i can't change the format for some reason. 

 

Currently it appears as YYYY-DD-MM and I want MM-DD-YYYY. 

 

When I run the workflow, i get that MM-DD-YYYY is not a valid date. 

 

Any reason as to why you think i get that error? 

AliAS2020
8 - Asteroid

@sabidor829 

 

What method did you use? are you sure that the date type for the origin is Date?

sabidor829
7 - Meteor

sabidor829_0-1594683875659.png

I used a select tool to convert it to a date and now I am setting the formula up. 

 

Thableaus
17 - Castor
17 - Castor

@sabidor829 

 

If you format the Date to your desired format, it stops being a Date Type and it needs to become a string type. So you need to convert to "String".

 

The only Date format allowed to a Date type in Alteryx is YYYY-MM-DD.

 

That being said, follow the instructions I already sent on the 2nd post:

 

- Use the ToDate([Field]) expression to get rid of the HH:MM:SS

- Convert your field to String

- Use the DateTimeFormat expression.

 

Cheers,

sabidor829
7 - Meteor

Thank you

Labels