Time format Conversion changing the date

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” } )

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” } )

1 Like

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