Your BETWEEN statement has X AND Y inside of parenthesis. No parenthesis are needed, the format is:
BETWEEN X AND Y not BETWEEN (X AND Y) See: https://www.postgresql.org/docs/current/functions-comparison.html Postgres is complaining about the EXCEPT because it is waiting for the next item in the BETWEEN clause. It just happened to be in the line of fire - any other word would have triggered an error as well. Cheers, Greg -- Crunchy Data - https://www.crunchydata.com Enterprise Postgres Software Products & Tech Support