Let's say you want to get an integer that is the number of months between two dates in psql (payment_date and creation_date are dates), and the following command:
select extract(month from (payment_date - creation_date) * interval '1 day') from invoice;fails with:
ERROR: function pg_catalog.date_part(unknown, integer) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
You have to multiply by interval '1 day', because the difference of dates in an integer and not an interval:
select extract(month from (payment_date - creation_date) * interval '1 day') from invoice;