Hello,
I've noticed that the newer version of a!fromJson() parses DataTime value differently, which results in receiving a different date value than the one received. I am looking for a bullet-proof way of setting the correct timezone and receiving the original date.
For example, the integration returns DateTime value like:
"dateOfBirth":"1955-08-03T00:00:00+02:00"
When using a!fromJson(), the resulting Map gets the value:
dateOfBirth=02/08/1955 23:00
I've tried playing with local(), but the dates still get switched up if the hour values are close to midnight. The a!fromJson19_r2 still returns the correct date.
Thanks for ¨your help!
Discussion posts and replies are publicly visible
The problem is, that the source system is sending a datetime value, instead of a date-only value.
You can try to use the gmt() function to strip the offset after the initial JSON parsing.
datevalue(left(tostring(local!yourIntegrationResult.dateOfBirth), 10))Sample code
a!localVariables( local!rawJson: "{" & char(34) & "dateOfBirth" & char(34) & ":" & char(34) & "1955-08-03T00:00:00+02:00" & char(34) & "}", local!parsedMap: a!fromJson(local!rawJson), local!wrongDate: local!parsedMap.dateOfBirth, local!rawDateText: left(tostring(local!parsedMap.dateOfBirth), 10), local!correctedDate: datevalue(local!rawDateText), { "Wrong Date: " & local!wrongDate, "Raw Text: " & local!rawDateText, "Correct Date: " & local!correctedDate } )
You can work with the json data and format it to extract the date value received. For example
a!localVariables( local!dateReceived: a!toJson( { "dateOfBirth": "1955-08-03T0:00:00+02:00" } ), trim(replace(split( a!jsonPath(local!dateReceived, "dateOfBirth"), "T")[1], 1, 1, " ")) )