Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    David Ritchie
    Filter format for date between in Rest APIAnswered
    Topic posted October 30, 2019 by David RitchieBlue Ribbon: 750+ Points, tagged REST 
    21 Views, 2 Comments
    Title:
    Filter format for date between in Rest API
    Summary:
    Format for an analyticsReport filter for date between
    Content:

    Hi,

    I'm trying to use the RESTful API to trigger an analyticsReportResults programmatically.  This is working fine but now I am trying to pass through a filter.  I looked in the documentation and it hows how to send a filter for name but my report has a filter which is between two dates.  I can't find anything in the documentation which shows how these two dates should be formatted.  I don't know if each date is a different filter, or if they both go in the same filter with some kind of differentiation.

    Any help appreciated,

    Dave

    Version:
    19B

    Best Comment

    Robert Surujbhan

    Hi David, here is the correct syntax for a "between" date filter when executing a report via the REST API.

    If your report ID was 12345 and the filter was named dateRange:

    {
        "id": 12345,
        "filters": [
            {
                "name": "dateRange",
                "values": ["2019-10-11", "2019-10-16"]
            }
        ]
    }
    

    The "yyyy-mm-dd" format as seen above works for both Date and Date/Time fields.  For Date/Time fields, you can also optionally pass UTC values in ISO 8601 format like this:

    {
        "id": 12345,
        "filters": [
            {
                "name": "dateRange",
                "values": ["2019-10-11T14:09:52.000Z", "2019-10-16T17:18:20.000Z"]
            }
        ]
    }
    

    Hope this helps!

    Comment

     

    • Robert Surujbhan

      Hi David, here is the correct syntax for a "between" date filter when executing a report via the REST API.

      If your report ID was 12345 and the filter was named dateRange:

      {
          "id": 12345,
          "filters": [
              {
                  "name": "dateRange",
                  "values": ["2019-10-11", "2019-10-16"]
              }
          ]
      }
      

      The "yyyy-mm-dd" format as seen above works for both Date and Date/Time fields.  For Date/Time fields, you can also optionally pass UTC values in ISO 8601 format like this:

      {
          "id": 12345,
          "filters": [
              {
                  "name": "dateRange",
                  "values": ["2019-10-11T14:09:52.000Z", "2019-10-16T17:18:20.000Z"]
              }
          ]
      }
      

      Hope this helps!