cancel
Showing results for 
Search instead for 
Did you mean: 

Date formatting

Harsha3
New Contributor III

Hi ,

I am trying to convert a local-date-time format to dd-MMM-yy ( say for eg :13-NOV-19).
I tried various methods still could not achieve this . It could be useful if I have a method to achieve this

Thanks in advance

image

11 REPLIES 11

dmiller
Admin Admin
Admin

From what I’m seeing you can use dd-MMM-yy, for example, Date.now().toLocaleDateString({“format”:“dd-MMM-yy”}) returns “27-Jul-20”.

I don’t think you Timestamp value is in one of the standard formats that we typically parse (See Parsing a Date on the Expression Language Examples page of our documentation), so you may need to follow the parsing a non-standard example of Date.parse($NonStandardDate, “dd-MMM-yy”)

Is Timestamp showing as a date-time field or a string? If it’s being treated as a string, then some other things will need to be done first.


Diane Miller
Community Manager

Harsha3
New Contributor III

Hi Dmiller,

Hope you are fine . Thanks for the reply my incoming date is of local-date time type . Even after using the above condition Date.now().toLocaleDateString({“format”:“dd-MMM-yy”}) it returns the value as 2020-07-27 instead of 27-JUL-20 . Please advise on the same

image

image

Hi Harsha,

Good day, since the IF_ROW_PROCSSED_DT is already a Date data type you can directly invoke the method in the object

e,g,

$IF_ROW_PROCSSED_DT.toLocaleDateString({“format”:“yy-MMM-dd”})

FYI, my sample data type is date-time if error “method doesn’t exists” on your end… try

Date.parse($IF_ROW_PROCSSED_DT.toString()).toLocaleDateString({“format”:“yy-MMM-dd”})

image

Thanks,
EmEm

dmiller
Admin Admin
Admin

Dev recommended trying: Date.now().toLocaleDateTimeString({“format”:“dd-MMM-yy”}) instead.


Diane Miller
Community Manager