Search code examples
questdb

Custom timerange in QuestDB?


I'm currently doing queries like

where startTs > '2021-04-18T00:00:00.000000Z'
      and startTs <= '2021-05-17T00:00:00.000000Z'

It's not 1 month of data but intervals around 25 days. I wondering if there is a shorter syntax to query data between timestamps in QuestDB.


Solution

  • The shorter syntax would be

    where startTs > '2021-04-18'
          and startTs <= '2021-05-17'
    

    so that 0 time is optional. Time can be specified up to any precision

    where startTs > '2021-04-18T12'
          and startTs <= '2021-05-17T12'
    

    also there is special syntax to query interval of 29 days but it includes start microsecond of 2021-04-18T00:00:00.000000Z and excludes end microsecond of 2021-05-17T00:00:00.000000Z

    where startTs IN '2021-04-18;29d'