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....
Solved! Go to Solution.
Hi @Raj008
You can use a regex like below to get only date.
REGEX_Replace([Field1], "(.+)\s(.+)", "$1")
Workflow:
Hope this helps : )
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:
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...
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
Hi @Raj008 ,
Please find attached a sample solution to achieve this.
Do let me know if this resolves your query.
Best,
Jagdeesh
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.
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 : )