Re: Date variables in psql - Mailing list pgsql-general

From Tom Lane
Subject Re: Date variables in psql
Date
Msg-id 181.1097169950@sss.pgh.pa.us
Whole thread Raw
In response to Date variables in psql  (Francisco Reyes <lists@natserv.com>)
Responses Re: Date variables in psql
List pgsql-general
Francisco Reyes <lists@natserv.com> writes:
> Trying the following simple sql file:
> \set proc_date 6/30/2004
> \echo Date is :proc_date
> select * from feeds where date = :proc_date limit 20;

That's going to expand to

select * from feeds where date = 6/30/2004 limit 20;

whereas what you need is

select * from feeds where date = '6/30/2004' limit 20;

It's fairly painful to get single quotes into a psql variable;
AFAIK you have to do it like this:

\set proc_date '\'6/30/2004\''

            regards, tom lane

pgsql-general by date:

Previous
From: Steve Atkins
Date:
Subject: Re: pre-sroted table (w/ index)
Next
From: Scott Frankel
Date:
Subject: Re: interfaces for python -- thanks