sqlpostgresqldate-range

Interval (days) in PostgreSQL with two parameters


In this query:

Select * from table where future_date - CURRENT_DATE <= '10';

It returns the interval of 10 days or less.

How to add two parameters? Example:

Select * from table where future_date - CURRENT_DATE <= '10' AND >= '30';

I already tried:

Select * from table where future_date - CURRENT_DATE BETWEEN '10' AND '30'

But it doesn't work.


Solution

  • SELECT  *
    FROM    mytable
    WHERE   future_date BETWEEN CURRENT_DATE + '10 days'::INTERVAL AND CURRENT_DATE + '30 days'::INTERVAL