skip to Main Content

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’…

2

Answers


  1. between only expects the values:

    select id
    
    from pricing 
    
    where current_Date between '2022-10-19' AND '2022-10-20';
    
    Login or Signup to reply.
  2. 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'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search