Search code examples
domo

Beast Mode to Convert text to date


I am trying to convert a string to date...

STR_TO_DATE(`MFGDTE`,'%Y-%m-%d')

But I am getting the value as 2019-12-18t00:00-06:00. Can you please let me know how to get just the date 2019-12-18.


Solution

  • The STR_TO_DATE() function actually returns a DateTime object, not just a Date, but it's easy to convert to a Date and remove the time component, like this:

    DATE(STR_TO_DATE(`MFGDTE`,'%Y-%m-%d'))
    

    which will return, e.g. 2019-12-18.