Reputation: 1760
I have next part of query:
AND date_part('day', some_date::date - first_day::date + interval '1 day') = some_daye
and I am getting next error:
ERROR: operator does not exist: integer + interval
How I can cast 'some_date - first_day' to interval?
Upvotes: 0
Views: 953
Reputation: 12494
Subtracting a date
from a date
yields an integer
.
An integer
cannot be cast to an interval
.
Cast either of your date
values to timestamp
to get an interval
.
e.g. AND date_part('day', some_date::timestamp - first_day + interval '1 day') = some_daye
Or you could simplify the entire expression as AND some_date - first_day + 1 = some_daye
Upvotes: 1