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?
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:
- Just use a Select Tool and change the datatype from DateTime to date. Just make sure the size of the column is 10.
- 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.