06-06-2021 04:34 AM
Hi,
I have a element as:-
jsonPath($, “$Z_ORD.IDOC.DK02[].DATE")
and value is coming as 20210521(yyyymmdd).
I need to convert it to 2021-05-21 and map it to target ml element.
I am using mapper. Tried like below:-
Date.parse(jsonPath($, "$Z_ORD.IDOC.DK02[].DATE”,“yyyMMdd”)).toLocaleDateTimeString({“format”:“yyyy-MM-dd”}) || null
but getting error as:-
Not-a-number (NaN) does not have a method named: toLocaleDateTimeString, found in: …:“yyyy-MM-dd”}). Perhaps you meant: toString, toExponential, toPrecision, toFixed
Solved! Go to Solution.
06-06-2021 01:54 PM
I ment at the end of my expression which parsed your date.
Date.parse($Z_ORD.IDOC.DK02.map(x=>x.DATE.toString().substring(0,4)).concat($Z_ORD.IDOC.DK02.map(x=>x.DATE.toString().substring(4,6)),$Z_ORD.IDOC.DK02.map(x=>x.DATE.toString().substring(6))).join(“-”)).toLocaleDateString()
06-06-2021 01:47 PM
Hi @bojanvelevski ,
I already tried using toLocaleDateString but it is throwing error:-
Not-a-number (NaN) does not have a method named: toLocaleDateTimeString, found in: …:“yyyy-MM-dd”}). Perhaps you meant: toString, toExponential, toPrecision, toFixed
06-06-2021 01:54 PM
I ment at the end of my expression which parsed your date.
Date.parse($Z_ORD.IDOC.DK02.map(x=>x.DATE.toString().substring(0,4)).concat($Z_ORD.IDOC.DK02.map(x=>x.DATE.toString().substring(4,6)),$Z_ORD.IDOC.DK02.map(x=>x.DATE.toString().substring(6))).join(“-”)).toLocaleDateString()
06-06-2021 02:08 PM
@bojanvelevski
Thank you, it worked.