UiPath Forms - convert json output result of Date to another format

Uipath Forms return forms data in a jason object.
Im trying to use Date/Time from Forms…
I have disable the Time from DateTime activity of Forms and I have changed the date formate to (dd.MM.yyyy)
output of json object showing that result.

jsonoutput

The result is perfect except i have to split that so I do not take time.

When I read this Start and End date as
variable is string (strStartDate = jsonOutput(“StartDate”).ToString)

I get a result
stringvalue

And my question is why the jsonobject result and string result is different ?

jsonobject result is what i need so why its changing and how can i solv it.

that is the reason that i did formate change in DateTime jsonscript so that It wont give me wrong answer but still its changing when reading as string.

thanks if anyone can help

Hi @Latif,
It’s probably because json keeps it as datetime type. You can try to deserialize json.

JSON does not know anything about dates. What .NET does is a non-standard hack/extension. The problem with dates in JSON and really JavaScript in general – is that there’s no equivalent literal representation for dates. In JavaScript following Date constructor straight away converts the milliseconds since 1970 to Date as follows:

var jsonDate = new Date(1297246301973);

Then let’s convert it to js format:

var date = new Date(parseInt(jsonDate.substr(6)));

The substr() function takes out the /Date( part, and the parseInt() function gets the integer and ignores the )/ at the end. The resulting number is passed into the Date constructor .

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.