Alteryx Designer Desktop Discussions

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

Formula tool Question on date to string

Vsridharan
6 - Meteoroid

When I use the formula tool to give me the date in the following format (mmddyyyy) as a string, I get MDDYYYY when it is a month before October, 

 

How can I get 04 or 08 instead of 4 or 8. and is there an easier way to do this.

 

Formula used:

"ToString(DateTimeMonth([Date]))+tostring(DateTimeDay([Date]))+tostring(DateTimeYear([Date]))"

 

Thanks in advance.

V

8 REPLIES 8
Prometheus
12 - Quasar

@Vsridharan Try this: DateTimeParse([Date],'%m%d%Y')

Vsridharan
6 - Meteoroid

I tried using the formula, but I am getting a null on the result.:(

Prometheus
12 - Quasar

@Vsridharan Can you please upload some dummy data just so I can put the data into a workflow?

Prometheus
12 - Quasar

@Vsridharan This is the workflow I'm using.

Vsridharan
6 - Meteoroid
Unfortunately I am unable to attach files/screenshot on my work system, Sorry about that
 

But I am basically using a text input tool for just 1 Column with a header called date and only 1 row with the value "2023-10-20". 

 

I was testing different dates with the date interface tool.

 

 

Prometheus
12 - Quasar

@Vsridharan Try this one.

Vsridharan
6 - Meteoroid

Thank you so much, This is perfect. and thanks to your solution I got to learn about Padleft and padright as well.

 

However I still do not understand why the first file you uploaded with the parse function had hyphens despite the formula [ DateTimeParse([Date],'%m%d%Y') ] not having any in it.

 

Thanks,

V

Prometheus
12 - Quasar

@Vsridharan Check out this help page. It's been super helpful to me over the years: https://help.alteryx.com/20231/designer/datetime-functions. DateTimeParse is looking for a field that has your date in it, regardless of format. This part of the expression "%m%d%Y" identifies the current state of the date. "%m" means a 2-digit month, "%d" means a 2-digit day, and "%Y" means a 4-digit year. I identified my original date field as being in that format, so the expression turned the data into an actual date that Alteryx recognizes, or YYYY-mm-dd.

Labels