Re: Comparing Dates

From: Guy Fraser <guy(at)incentre(dot)net>
To: PgSQL - SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Comparing Dates
Date: 2004-11-19 16:05:03
Message-ID: 419E19AF.9030405@incentre.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

You should use single quotes for all literals.

Examples:
select '2004-06-08' ;
?column?
------------
2004-06-08

select 'user' ;
?column?
----------
user

Failing to quote literals will cause unexpected results.

Examples:
select 2004-06-08 ;
?column?
----------
1990

select user ;
current_user
--------------
guy

"Thomas F.O'Connell" <tfo(at)sitening(dot)com> writes:

> select 2004-06-08;
> ?column?
> ----------
> 1990
>
> I'm not exactly sure how the bare string is converted internally, but
> it's
> clearly not a complete date like you're expecting.

--
Guy Fraser
Network Administrator
The Internet Centre
780-450-6787 , 1-888-450-6787

There is a fine line between genius and lunacy, fear not, walk the
line with pride. Not all things will end up as you wanted, but you
will certainly discover things the meek and timid will miss out on.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2004-11-19 16:23:09 Re: transactions in functions, possible bug or what I'm doing
Previous Message Passynkov, Vadim 2004-11-19 15:57:12 Re: get sequence value of insert command