T
T
Tayrus02021-12-08 17:45:42
PostgreSQL
Tayrus0, 2021-12-08 17:45:42

How to get data from 2021-01-01 to 2020-01-01 inclusive from the database?

I have a date column where the timestamp is stored, I want to get data from 2021-01-01 to 2020-01-01 inclusive, how can I do this?

Tried something like this but it gives wrong result

SELECT COUNT(*) FROM tableee where date > (CURRENT_DATE - INTERVAL '3 months') - INTERVAL '7 months';

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2021-12-08
@Tayrus0

SELECT * FROM table t WHERE t.date BETWEEN '2020-01-01 00:00:00'  AND  '2021-01-01 23:59:59'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question