Alteryx: Changing DateTime to Date via Formula
Question ID: 109807

I am trying to change a field in the format ‘yyyy-mm-dd hh:mm:ss’ from a DateTime datatype to a Date datatype ‘yyy-mm-dd’. I am accomplishing this in the Formula tool with Left([DateTimeField], 10) but I am unable to change the data type in the formula tool and the output still has the full DateTime format in spite of the Left function.

Any idea how I can accomplish this?

Marked as spam
Posted by (Questions: 17, Answers: 0)
Asked on August 26, 2020 11:42 am
Answers (1)
Private answer

There are several ways to accomplish your goal. I assume in the Formula tool you are using, the output column is the same column you are manipulating (in this case [DateTimeField]). Alteryx does not allow you to change the data type in the formula tool for a pre-existing field. You could just name a new column in the formula tool ([DateField]), and now Alteryx will allow you to change the data type within the Formula tool.

You could also avoid the formula tool altogether and do one of the two:

  1. Just use a Select Tool and change the datatype from DateTime to date. Just make sure the size of the column is 10.
  2. If you want to keep the time but have it in a separate column, split the column using the Text to Columns Tool with s as a delimiter. Then change the respective datatypes to Date and Time.

Hope that helps!

Marked as spam
Posted by (Questions: 0, Answers: 17)
Answered on August 26, 2020 12:46 pm

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

Scroll to Top