Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Date format - v_string to date

Raj008
8 - Asteroid

Hi All,

 

I need to convert a date format, which is 1/12/2020 0:00 (V_String), to 1/12/2020.

 

Thanks in advance,

Raj....

7 REPLIES 7
atcodedog05
22 - Nova
22 - Nova

Hi @Raj008 

 

You can use a regex like below to get only date.

REGEX_Replace([Field1], "(.+)\s(.+)", "$1")

 

Workflow:

atcodedog05_0-1626974234977.png

 

Hope this helps : )

phottovy
13 - Pulsar
13 - Pulsar

Are you trying to keep it as a string or convert it to a date type? If you are looking to convert it, you should try using the DateTime tool:

datetime-tool 

apathetichell
18 - Pollux

is that December 1st or January 12th?

 

December 1st:

datetimeparse([Field1],"%d/%m/%Y") (formula tool - new field date)

January 12th:

datetimeparse([Field1],"%m/%d/%Y") (formula tool -  new field date)

 

 

datetime

December 1st:

datetimeparse([Field1],"%d/%m/%Y %H:%M:%S") (formula tool - new field datetime)

January 12th:

datetimeparse([Field1],"%m/%d/%Y %H:%M:%S") (formula tool -  new field datetime)

 

fixed...

Raj008
8 - Asteroid

Hi apathetichell,

 

The date is January 1st...can you please provide me with a workflow and explain how this works.....the input data is 1/12/2021 0:00, i need it in a data format of 1/12/2021.

 

Thanks

JagdeeshN
12 - Quasar
12 - Quasar

Hi @Raj008 ,

 

Please find attached a sample solution to achieve this.

 

Do let me know if this resolves your query.

 

Best,

Jagdeesh

apathetichell
18 - Pollux

Hi @Raj008 o.k. so 1/12/2021 is either December 1st or January 12th. January 1st 1/1/2021. But here's the key - I need to know which column is date and which column is month:

December 1st:

datetimeparse([Field1],"%d/%m/%Y") (formula tool - new field date)

January 12th:

datetimeparse([Field1],"%m/%d/%Y") (formula tool - new field date)

 

The first tool has "%d" first - that means it's day/month/Year

 

the second tool has "%m" first - that means it's month/day/Year

 

Datetimeparse converts a string to date based upon how the string is configured and what datetime format options are provided... The direct string to date comparison in Alteryx is "2021-01-01" for January 1st, 2021. or "2021-01-02" for January 2nd (ie YYYY-mm-dd)... you can capture the hours/minutes/seconds as well. and you can even capture everything and then extract the string components you need.

atcodedog05
22 - Nova
22 - Nova

Hi @Raj008 

 

Doesn't my solution help in your scenario. If not please provide me feedback on why its not working. So that I can amend my workflow accordingly 🙂

 

Happy to help : )

Labels