Search by date range

chklffchklff Member Posts: 5

How can I search entities in business (products for example by date range?

If I use only before OR after it works but when they combined API returns nothing

Here is example of that query:

query { business(id: "xxxxxxxxxx") { id products(page:1, pageSize:100 sort:CREATED_AT_DESC, modifiedAtAfter:"2019-09-01T21:54:25.975Z" modifiedAtBefore:"2020-08-29T21:54:25.975Z")

It does return the only order created several months ago BUT not products I've added several hours ago...

Bellow full-example

{
"response": {

    "body": {
        "data": {
            "business": {
                "id": "QnVzaW5lc3M6NWQyMDMxY2QtNzdjNC00ZjMzLTllZmItZTdlYzFkNjViODQ1",
                "products": {
                    "pageInfo": {
                        "currentPage": 1,
                        "totalPages": 1,
                        "totalCount": 6
                    },
                    "edges": [
                        {
                            "node": {
                                "id": "QnVzaW5lc3M6NWQyMDMxY2QtNzdjNC00ZjMzLTllZmItZTdlYzFkNjViODQ1O1Byb2R1Y3Q6Mzg1MjcwOTY=",
                                "createdAt": "2020-01-02T03:18:30.000Z",
                                "modifiedAt": "2020-01-02T03:18:30.000Z",
                                "name": "test3",
                                "description": "test",
                                "isSold": true,
                                "isBought": true,
                                "isArchived": false,
                                "unitPrice": "1",
                                "incomeAccount": {
                                    "name": "Sales",
                                    "displayId": null
                                },
                                "expenseAccount": {
                                    "name": "Computer – Internet",
                                    "displayId": null
                                }
                            }
                        },

......

                        {
                            "node": {
                                "id": "QnVzaW5lc3M6NWQyMDMxY2QtNzdjNC00ZjMzLTllZmItZTdlYzFkNjViODQ1O1Byb2R1Y3Q6MzgzNTQ1NzU=",
                                "createdAt": "2019-12-26T00:00:39.000Z",
                                "modifiedAt": "2019-12-26T00:00:39.000Z",
                                "name": "test prod",
                                "description": "",
                                "isSold": true,
                                "isBought": false,
                                "isArchived": false,
                                "unitPrice": "10",
                                "incomeAccount": {
                                    "name": "Sales",
                                    "displayId": null
                                },
                                "expenseAccount": null
                            }
                        }
                    ]
                }
            }
        }
    }
},
"request": {
    "url": "https://gql.waveapps.com/graphql/public",
    "headers": {
        "user-agent": "Integromat/production",
        "authorization": "***",
        "content-type": "application/json"
    },
    "method": "POST",
    "body": {
        "query": "query {  business(id: \"QnVzaW5lc3M6NWQyMDMxY2QtNzdjNC00ZjMzLTllZmItZTdlYzFkNjViODQ1\")  {    id    products(page:1, pageSize:100 sort:CREATED_AT_DESC, modifiedAtAfter:\"2019-09-01T22:37:15.789Z\", modifiedAtBefore:\"2020-09-01T22:37:15.790Z\"){     pageInfo {        currentPage        totalPages        totalCount      }      edges {        node {          id          createdAt          modifiedAt          name    description  isSold isBought isArchived  unitPrice  incomeAccount{name displayId}          expenseAccount{name displayId}        }      }    }  }}"
    }
}

}

But if I do request ONLY with created after like bellow it works fine:

    "body": {
        "query": "query {  business(id: \"QnVzaW5lc3M6NWQyMDMxY2QtNzdjNC00ZjMzLTllZmItZTdlYzFkNjViODQ1\")  {    id    products(page:1, pageSize:100 sort:CREATED_AT_DESC, modifiedAtAfter:\"2020-09-01T21:41:00.950Z\"){     pageInfo {        currentPage        totalPages        totalCount      }      edges {        node {          id          createdAt          modifiedAt          name    description  isSold isBought isArchived  unitPrice  incomeAccount{name displayId}          expenseAccount{name displayId}        }      }    }  }}"
    }

thanks!

Comments

  • RobVGRobVG Member Posts: 53 admin

    Hi @chklff,

    Can you confirm your expectations for me:

    First query searches between a range where 2019-09-01T22:37:15.789Z < modifiedAt < 2020-09-01T22:37:15.790Z. The same thing applies for 2019-09-01T21:54:25.975Z < modifiedAt < 2020-08-29T21:54:25.975Z.

    Second query searches 2020-09-01T21:41:00.950Z < modifiedAt.

    [The first query] does return the only order created several months ago BUT not products I've added several hours ago...

    Which products were you expecting to have received in the first query? Note the upper bound set may be before "several hours ago". When providing modifiedAtAfter and modifiedAtBefore, both conditions need to be met.

    Regards,
    Rob

  • chklffchklff Member Posts: 5

    Hey @RobVG
    Thanks, You pointed on my issues, I used a local EST time instead of UTC that data stored in your DB... so SOLVED!
    Thanks!

  • RobVGRobVG Member Posts: 53 admin

    Great! Happy to hear this issue has been resolved. Time zones are tricky.

Sign In or Register to comment.