Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

GraphQL createdAt date range missing orders.

GraphQL createdAt date range missing orders.

bookkeepapp
Shopify Partner
9 0 1

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
            }
Founder of bookkeep.com
Reply 1 (1)

hassain
Shopify Staff (Retired)
624 104 189

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.

 

To learn more visit the Shopify Help Center or the Community Blog.