Home > other >  Checking if today's date is in between the given start date and end date
Checking if today's date is in between the given start date and end date

Time:12-15

The code is written in postgresql and run in pgadmin 4.

I am trying to get the id from the pricing table if the current date lies in between the given start date and end date.

I am trying to get the id from the pricing table if the current date lies in between the given start date and end date.

select id

from pricing 

where current_Date between start_date>=date '2022-10-19' AND end_date<=date '2022-10-20';

The error raises

operator does not exist: date >= boolean LINE 3: where current_Date between start_date>=date '2022-10-19'...

CodePudding user response:

Your where condition is essentially someDate between someBoolean and someOtherBoolean, which confuses compiler. Use just this:

where current_Date between date '2022-10-19' AND date '2022-10-20'

CodePudding user response:

between only expects the values:

select id

from pricing 

where current_Date between '2022-10-19' AND '2022-10-20';
  • Related