Weird behavior with datetimes

This expression:

DateAdd(DateInterval.Hour,-48,Now.ToUniversalTime).ToString("yyyy-MM-ddTHH:mm:ssZ")

…does not give me formatted output, I just get 01/25/2026 19:29:40

If I break it up:



Then using Log Message output the values, firstString shows 2026-01-25T and secondString shows 19:29:40Z

But if I do:

firstString + secondString

or

String.Concat(firstString,secondString)

It gives me the wrong format:

01/25/2026 19:29:40

What the heck is happening?! I’m sure the original expression was working because I used it in an API call (Orchestrator HTTP Request) and it properly returned data. We published to production and ran it, got a HTTP 400 error. I open the project today, and now I’m getting this weird result where it won’t output the format.

Even if I just literally type the values out in the Assigns:

When I Log Message “firstString + secondString” it gives me 01/25/2026 19:29:40

Hi,

It seems Studio matter.

As well as timestamp field is converted to specific date time style, message field is also converted. Actual data in log file is correct value.

I hope it will be fixed in the future release.

Regards,

Hi @postwick

UiPath is implicitly converting the values back to DateTime when you concatenate them, so it applies the system date format (01/25/2026 19:29:40).

To avoid this, format the DateTime in one step or force pure string concatenation, for example:
DateAdd(DateInterval.Hour, -48, Now.ToUniversalTime).ToString(“yyyy-MM-ddTHH:mm:ssZ”)
or use string interpolation like $“{firstString}{secondString}”.

1 Like

Yeah and it shouldn’t do that, since they are strings.

DateAdd(DateInterval.Hour, -48, Now.ToUniversalTime).ToString(“yyyy-MM-ddTHH:mm:ssZ”)

That does the same thing, it does not output the specified format. That’s why I ended up going down this rabbit hole of trying to find a way to break it up to get the desired value.

By the way, for anyone seeing this post, I had this:

DateAdd(DateInterval.Hour, -48, Now.ToUniversalTime).ToString(“yyyy-MM-ddTHH:mm:ssZ”)

…as part of a longer expression in a Orchestrator HTTP Request activity:

"/odata/Jobs?$select=Id&$filter=EndDate gt " + DateAdd(DateInterval.Hour, -48, Now.ToUniversalTime).ToString(“yyyy-MM-ddTHH:mm:ssZ”)

In that context, within that activity, the formatting IS working correctly. It just seems to be the Log Message/Write Line activities that are re-converting the strings back to datetime. The automation was faulting at the Orchestrator HTTP Request activity, so I thought the expression was the problem, but it wasn’t (it was a permissions issue).

EDIT: I just realized, and tested, that it appears the above expression works because the “/odata/Jobs…” part is a string and it can’t be a date in a string. If I do this:

Then it works even in a Log Message:

image

So it seems like the issue is when you’re concatenating two or more strings that could be interpreted as datetimes, then the problem happens. If any of the strings can’t be interpreted as dateimes, then you don’t see this problem.

1 Like

@loginerror hoping someone from UiPath sees this post. This needs to be fixed. I tested in the latest 25.x version of UiPath.System.Activities and it still does the same thing.

Let me discuss this internally (probably with the Studio team). From what I remember off the top of my head, it’s the Studio that manipulates the Output panel entry. So you can never win this war as long as the date string looks like something “parsable”.

I can confirm that this is a Studio behaviour. It’s tracked internally as a bug though.

1 Like

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