Get balances BETWEEN two dates

The following query does not work when time selector is “between”, while it works with “till” or “before”.
BitQuery throws the following message:

{“message”: “This selector can not be applied to time, use ONLY till or before”, “locations”: [ { “line”: 5, “column”: 7 } ], “path”: [ “ethereum”, “address”, 0, “balances” ] } ]

{
  ethereum (network: bsc){
    address(address: {is:  $address}) {      
      address
      balances(
        currency: {is: $currency}
        time: {between: ["2021-05-12T13:01Z", "2021-05-21T13:01Z"]}
      ) {
        currency {
          symbol
          address
          name
          decimals
        }
        value
        history {
          block
          value
          transferAmount
          timestamp
        }
      }
    }
  }
}

To get a balance till a point in time you can use the following query

{
  ethereum (network: bsc){
    address(address: {is:  "0xfE54C0A978B477Fc06faBa4a822516977E931eA9"}) {      
      address
      balances(
        currency: {is: "0x83a86adf1a7c56e77d36d585b808052e0a2aad0e"}
        time: {till: "2021-06-12T13:01Z"}
      ) {
        currency {
          symbol
          address
          name
          decimals
        }
        value
        history {
          block
          value
          transferAmount
          timestamp
        }
      }
    }
  }
}

HI @gaurav
Thanks for your reply.

Yes, I know I can do that, but i’d like to specify a time range BETWEEN two points in time, not till or before.

Have you tried using

time: { between: [$from, $till] }

Of course

And i get

{“message”: “This selector can not be applied to time, use ONLY till or before”, “locations”: [ { “line”: 5, “column”: 7 } ], “path”: [ “ethereum”, “address”, 0, “balances” ] } ]

Oh, I should have tried it myself… Sorry!

Try this maybe? Using both since and till:

{
  ethereum (network: bsc){
    address(address: {is:  "0xfE54C0A978B477Fc06faBa4a822516977E931eA9"}) {      
      address
      balances(
        currency: {is: "0x83a86adf1a7c56e77d36d585b808052e0a2aad0e"}
        time: {since: "2021-05-12T13:01Z" till: "2021-05-21T13:01Z"}
      ) {
        currency {
          symbol
          address
          name
          decimals
        }
        value
        history {
          block
          value
          transferAmount
          timestamp
        }
      }
    }
  }
}
1 Like

Hi, thanks for your advice

Unfortunately, this approach is not working. It only considers the till.

I believe for now, there is no way to get the balance between defined date, query only consider 1 parameter and ignore other.