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

Alteryx Designer Desktop Discussions

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

DateTimeParse - ConveError

Muralisagar
8 - Asteroid

 

HI All,   I need date in 'dd/mm/yyyy' format whereas I am getting it in 'yyyy-mm-dd'   I tried 'DateTimeParse' but there is an error, can you please help   Expression: datetimeparse(DateTimeNow(),"%d/%m/%y")
Error: ConvError: Formula (18): DATETIMEPARSE: Cannot convert "2020-08-17 15:49:22" to a date/time with format "%d/%m/%y": Expected separator '/%m/%y', got: '20-08-17 15:49:22'    
 
regards, Murali
5 REPLIES 5
echuong1
Alteryx Alumni (Retired)

Is the attached what you're looking for?

 

If your data is already a datetime, you can use the datetimeparse tool to convert it to a string with your desired format.

 

echuong1_0-1597689616226.png

 

Muralisagar
8 - Asteroid

Hi, thank you

 

this is good, but I want the outcome in date format for further calculations (not in the string format). please help

echuong1
Alteryx Alumni (Retired)

You cannot have that format for date values. The Alteryx recognized date format is Year-Month-Day. Any variation from this would turn the values into strings.

 

Is there a specific reason why you want the values in a different format? If it's more for presentation purposes, you'd need to create a second field with the values formatted different. I'd advise against this, as you're essentially duplicating values. This is the same as if you'd like monetary values shown with a "$" and commas.

 

I'd recommend keeping all values in the proper Alteryx recognized date format for all calculations, and then converting to your formatting string presentation if needed.

grazitti_sapna
17 - Castor

Hi @Muralisagar , in such cases where you require the date for calculations what you can do is do the calculations in alteryx standard date format that is yyyy-mm-dd and then convert it to dd/mm/yy at the end of the workflow before the output.

I hope this helps.

Thanks.

Sapna Gupta
RolandSchubert
16 - Nebula
16 - Nebula

Hi @Muralisagar ,

 

to perform calculations on dates, they have to be converted to a Date or DateTime data type using DateTimeParse - the format of a date in this data type always is "YYYY-mm-dd HH:MM:SS". After all calculations are finished, you can create the format you need using DateTimeFormat.

 

2020-08-18_08-21-09.png

So the first step is to use DateTimeParse to convert the values you currently have to DateTime data type (if the data type isn't already "DateTime").

Then you can execute calcultions and convert to the format you want, but after using DateTimeFormat to create this format, you can't you the output field for calculation.

 

I've attached a sample workflow, hope this is helpful. Let me know if it works for you.

 

Best,

 

Roland  

Labels