Jump to content

Filter results by DateTime

Jason Willis

Recommended Posts

Hoping someone can help with this as I can't find a clear answer...

I have a simple query to call from the servicedesk/tickets endpoint, but I'm unable to get the filter working with a DateTime column.

In the code block below, Filter 1 (on the TickerNumber) & Filter 2 (on the SLA Status) both work fine and give the expected results, but Filter 3 (on Actual Resolution) returns a (400): Bad Request error. It does this whether I create the datetime programmatically as in Filter3, or hard-code it as in Filter4.


    Token   = "TOKEN GOES HERE",
    BaseURL = "https://psa.pulseway.com/api/",
    Path    = "servicedesk/tickets",

        Day     = Date.Day(Date.From(DateTime.LocalNow())),
        Month   = Date.Month(Date.From(DateTime.LocalNow())),
        Year    = Date.Year(Date.From(DateTime.LocalNow())),

        Date    = DateTime.ToText(#datetime(Year, Month, Day, 00, 00, 00), "yyyy-MM-ddThh:mm:ss"),

        Filter1 = "?$filter=endswith(TicketNumber, '2022')",
        Filter2 = "?$filter=StatusSLAEventId gt 1",
        Filter3 = "?$filter=ResolutionActualTime gte " & Date,
        Filter4 = "?$filter=ResolutionActualTime gte 2022-01-03T00:00:00.000Z",

            Source = Json.Document(Web.Contents(BaseURL & Path & Filter4, [Headers = [Authorization="Bearer " & Token]]))

Does anyone know where I'm going wrong?

Thank you in advance!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...