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