Re: How to quote date value?

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How to quote date value?
Date: 2003-11-21 19:04:18
Message-ID: 20031121110022.U75942@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Fri, 21 Nov 2003, Gaetano Mendola wrote:

> nobody wrote:
> > I have found it in documentation, it is single quote. But it does not
> > explain why
> >
> > SELECT '1/11/2003' AS "InvoiceDate";
> >
> > returns "unknown" data type instead of "date".

(I haven't seen the original message yet, so I'm replying to a reply)
Date literals are generally written as:
DATE '1/11/2003'

PostgreSQL will try to guess what type you meant with quoted strings in
expressions, but in the above there isn't enough context to do guess that
you meant a date really (it should probably actually be thought of as a
string in such cases).

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2003-11-21 19:12:44 Re: cast varchar to numeric/money
Previous Message Greg Stark 2003-11-21 19:03:16 Re: Expressional Indexes