cancel
Showing results for 
Search instead for 
Did you mean: 

Convert UTC date to date

mtran21
New Contributor III

How do you convert this date “2020-09-01T00:00:00.000” to this “20200901”?

11 REPLIES 11

dmiller
Former Employee

I’m double checking, but I think you have to use one of the formats listed in the Parsing a Date example in the documentation.


Diane Miller

dmiller
Former Employee

@cjhoward18 to the rescue. 🙂
Date.parse("2020-09-01T00:00:00.000").toLocaleDateString({"format":"yyyyMMdd"})


Diane Miller

mtran21
New Contributor III

Thanks, will this work with variable?
Date.parse(“$HIRE_DATE”).toLocaleDateString({“format”:“yyyyMMdd”})

dmiller
Former Employee

You shouldn’t need the quotes around the variable, but it should work if it’s a string.


Diane Miller