QuestDB: select clause with WHERE do not work with timestamp field

Viewed 266

On a Questdb table I made some queries that are working, but when I tried to apply a where clause the field that has a timestamp type:

SELECT Timestamp_GMT, ValueCal 
FROM mytable 
WHERE Timestamp_GMT='2020-12-11T11:23:27.583036Z'

I got an error message:

unexpected argument for function: =. expected args: (STRING,STRING). actual args: (TIMESTAMP,STRING constant)

In the database, Timestamp_GMT has type timestamp and there are values with format displayed like 2020-12-11T11:23:27.583708Z

In the documentation, there are examples of where clause applied to timestamps, but I can't see my mistake: https://questdb.io/docs/reference/sql/where

Can you please help me?

1 Answers

Your Timestamp_GMT is probably not the designated timestamp of the table. Even though it's of type Timestamp it can only be filtered as

Timestamp_GMT=to_timestamp('2020-12-11T11:23:27.583036Z','yyyy-MM-ddTHH:mm:ss.SSSSSSZ')

Designated timestamp is a special column beast. You can do filtering on it like

designated_ts='2020-02-26'

This actually means not a single value but a range of all microseconds from 00:00:00.000000 to 23:59:59.999999 on Feb 26, 2020.

You can find more details on the relevant documentation.

Related