GraphQL createdAt date range missing orders

When I run this createdAt query I get 4 orders. But When I run the updatedAt query I get 5 orders. And the 5 orders are in the date range. So createAt is missing one order here. Why is that?

orders(query:"created_at:>2020-01-29T00:00:00-0500 AND created_at:<2020-01-30T00:00:00-0500", first: 100){
    edges {
      node {
        id,
        createdAt
       
      }
    }
    pageInfo {
      hasNextPage
    }
  }
"edges": [
                {
                    "node": {
                        "id": "gid://shopify/Order/1995500683362",
                        "createdAt": "2020-01-29T17:25:05Z"
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Order/1995794088034",
                        "createdAt": "2020-01-29T21:46:44Z"
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Order/1995888525410",
                        "createdAt": "2020-01-29T23:25:31Z"
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Order/1995945771106",
                        "createdAt": "2020-01-30T00:32:50Z"
                    }
                }

This is the updatedAt code and result:

orders(query:"updated_at:>2020-01-29T00:00:00-0500 AND updated_at:<2020-01-30T00:00:00-0500", first: 100){
    edges {
      node {
        id,
        createdAt
       
      }
    }
    pageInfo {
      hasNextPage
    }
  }
"edges": [
                {
                    "node": {
                        "id": "gid://shopify/Order/1995020271714",
                        "createdAt": "2020-01-29T05:16:15Z"
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Order/1995500683362",
                        "createdAt": "2020-01-29T17:25:05Z"
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Order/1995794088034",
                        "createdAt": "2020-01-29T21:46:44Z"
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Order/1995888525410",
                        "createdAt": "2020-01-29T23:25:31Z"
                    }
                },
                {
                    "node": {
                        "id": "gid://shopify/Order/1995945771106",
                        "createdAt": "2020-01-30T00:32:50Z"
                    }
                }
            ],
            "pageInfo": {
                "hasNextPage": false
            }
1 Like

Hey @bookkeepapp ,

If you are including the hour/minutes/seconds and timezone in your search query filter, be sure to wrap your timestamp with singular quotes. So for example, your query should look like this:

orders(query:"created_at:>'2020-01-29T00:00:00-0500' AND created_at:<'2020-01-30T00:00:00-0500'", first: 100){
    edges {
      node {
        id,
        createdAt
       
      }
    }
    pageInfo {
      hasNextPage
    }
  }

Right now without the single quotes, everything in your timestamp from the character ‘T’ and afterwards is completely ignored. So your query just becomes >2020-01-29 and < 2020-01-30, which is why the 5th order from the 30th is dropped. By having the single quotes, the entire contents of the timestamp with the hours/minutes/seconds and with the timezone will be included in the query filter.

8 Likes