cancel
Showing results for 
Search instead for 
Did you mean: 

Time format Conversion changing the date

Shrabanti
New Contributor II

I am doing date conversion. But not sure why it is changing the date.

Input Date is : “29-JUN-21 10.07.35.000000 AM”
Output date is becoming :“2020-12-27 10:07:35”

The conversion I am using is :
Date.parse($OrderDetailCreateDate,“dd-MMM-YY hh.mm.ss.SSSSSS aa”).toLocaleDateTimeString( { “format”:“yyyy-MM-dd HH:mm:ss” } )

2 REPLIES 2

Sowmya_Rayavara
New Contributor III

Hi Shrabanti,

Can you please try with the below date function? Just changed the year format ‘YY’ to ‘yy’

Date.parse(“29-JUN-21 10.07.35.000000 AM”,“dd-MMM-yy hh.mm.ss.SSSSSS aa”).toLocaleDateTimeString( { “format”:“yyyy-MM-dd HH:mm:ss” } )

bojanvelevski
Valued Contributor

Hi @Shrabanti ,

Your expression looks good, and only needs 2 changes. Year should be lowercase letters, and Hours should be uppercase. The expression needs to look like this:

Date.parse('29-JUN-21 10.07.35.000000 AM','dd-MMM-yy HH.mm.ss.SSSSSS aa').toLocaleDateTimeString( { "format":"yyyy-MM-dd HH:mm:ss" } )

@Sowmya_Rayavarapu’s expression is nearly identical, and also works.

Regards,
Bojan