Reputation: 810
I am beginner with Postgres. I want to select the rows where Today is greater than an Array of Dates that I have stored.
This is what i wrote which does not work (error)
SELECT
bool_or(now()::date @> a_date) AS some_of_the_dates_lies_within_range
FROM
(SELECT unnest(dateofdeparture) AS a_date from alerts) as S0;
This is how my row is
SELECT unnest(dateofdeparture) AS a_date from alerts
a_date
2019-01-12
2019-01-13
2019-01-14
2019-01-15
2019-01-16
2019-01-17
2019-01-18
Any pointers help would be much appreciated.
Upvotes: 0
Views: 429
Reputation: 31656
You are probably looking for the ANY
or ALL
operator on the ARRAY
type
Assuming that dateofdeparture
is a DATE[]
array , what you need is either
select * from alerts WHERE current_date > ANY (dateofdeparture);
OR
select * from alerts WHERE current_date > ALL (dateofdeparture);
Upvotes: 1