PostgreSQL What's the difference between NOW() - INTERVAL and its value

Viewed 100

I am working with PostgreSQL 12.6 and TimescaleDB.

I have an hypertable raws which contains a field "time" of type timestamp without time zone NOT NULL.

Now I have 2 queries:

select * from raws where time > NOW() - INTERVAL '15 day';

This one gives me this:

2021-04-08 00:00:00
2021-04-08 00:10:00
2021-04-08 00:20:00

And NOW() is equal to: 2021-04-20 16:48:41.575584+02

But now, if I take the value of NOW() - INTERVAL '15 day' which is, at this time 2021-04-05 16:48:41.575584+02, and put it my query like this:

select * from raws where time > '2021-04-05 16:48:41.575584+02';

It doesn't work anymore: I get 0 results, but no errors.

So what is it that makes the second query fail?

Is it something wrong with TimescaleDB or PostgreSQL, or am I missing something with formats?

1 Answers

So I tried to reproduce that bug on a fresh database, and everything worked fine.

The query select * from raws where time > '2021-04-05 16:48:41.575584+02'; stops working when I import all my datas from a dump, so even though I don't know exactly what, there is a problem with that dump.

Related