[This is probably really easy, but I've googled unsuccessfully for far too long]
I want to store a series of dates in variables in Postgres in order to run a series of queries against them:
\set SESSION startDate date'2018-04-01'
\set SESSION reportDate CURRENT_DATE
I then want to run a series of queries like
SELECT COUNT(id) FROM assets
WHERE target_date > :startDate
AND target_date < :reportDate;
My variable "reportDate" works fine, but can someone please tell me how to correctly set an arbitrary date as "startDate". I've tried all manners of escaping the value for the \set command unsuccessfully.
The error I get is:
ERROR: column "date2018" does not exist
I'm using PostgreSQL 9.3.22.
Many Thanks
\set SESSION startDate date'2018-04-01'to\set SESSION startDate '2018-04-01'or possibly\set SESSION startDate "'2018-04-01'"