Get Jobs - Time Filter Problems

I am building a process to pull all jobs that completed within the last 24 hours. However, I am getting some jobs back with an End Time more than 24 hours ago. Not sure what I’m doing wrong.

First I assign this - ReportTimeFrameDays is an argument, and is currently set to 1:

TimeFrame = Now.AddDays(-ReportTimeFrameDays)

Then, in the Get Jobs activity I filter like this:

"EndTime gt "+TimeFrame.ToString("yyyy-MM-dd")+"T"+TimeFrame.ToString("hh:mm:ss")+"Z"

I then ConvertFromUTC to Eastern Standard Time to get the correct start and end times for each row. In my output, nothing goes back further than the previous day, as I would expect, but I do get results for that day that ended more than 24 hours ago. I’m sure that I’m doing something wrong in the filter, but I’m not sure what it is.

Hi @jcarr79,

A simple time formatting is the issue here.

Troubleshooting steps:
We have PowerShell scripts which we set our filter on. It is equivalent to your TimeFrame variable with a -4 hours in your case it is -ReportTimeFrameDays variable.

In PowerShell we set the variable as
$timePast = (get-date).AddHours(-4).ToString("yyyy-MM-ddTHH\:mm\:ss.ffZ")

PS H:\> $timePast = (get-date).AddHours(-4).ToString("yyyy-MM-ddTHH\:mm\:ss.ffZ")
PS H:\> $timePast
2021-07-28T07:38:08.89Z

When I ran your TimeFrame variable and "EndTime gt "+TimeFrame.ToString("yyyy-MM-dd")+"T"+TimeFrame.ToString("hh:mm:ss")+"Z" in UiPath I get
image

So, I think there is a slight difference in the two strings. The one we use in our API calls gets us the logs from orchestrator so that must be the format the UiPath API requires.

The difference here is a ".ff", which is The hundredths of a second in a date and time value. before the Z
2021-07-28T07:38:08.89Z (PowerShell) vs. 2021-07-26T11:37:45Z (Your UiPath TimeFrame)

I am here assuming the Orcehstrator API does not understand the TimeFrame variable (requires .ffZ) of yours.

A workaround solution which should work for you:
Set a static hundredths of a second. Here I use “.01”

"EndTime gt "+TimeFrame.ToString("yyyy-MM-dd")+"T"+TimeFrame.ToString("hh:mm:ss")+".01"+"Z"


But if you really want an answer then you can try (I could not get the .ff formating in UiPath):
c# - Converting String Format “yyyy-MM-ddTHH:mm:ss.fffZ” to DateTime - Stack Overflow

More on date string formats: Custom date and time format strings | Microsoft Docs

Hope this helps you!

Thanks, the big issue actually turned out to be that I was used “hh” when I needed to use “HH”!

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