From: Tom Lane <tgl@sss.pgh.pa.us>
To: Eric McKeown <ericm@palaver.net>
Cc: pgsql-sql@hub.org
Subject: Re: date versus datetime?
Date: Sat, 01 Aug 1998 16:16:28 -0400
Message-ID: <18511.902002588@sss.pgh.pa.us> (raw)
In-Reply-To: <199808010332.XAA14257@hub.org>
Eric McKeown <ericm@palaver.net> writes:
> for instance, it seems I can do this with the date type:
> select * from table where date_field < some_date_I_specify_here
> However, if my reading of the manual and my experiments are correct, I
> can't perform that sort of operation with the datetime type.
You certainly can do that with datetime; I do it all the time.
Without seeing a concrete example, I'm not sure why it's not working for
you. Perhaps you are writing the comparison date in a format that's
acceptable for type "date" but not for "datetime"? That doesn't seem
very likely though; datetime's parser is relatively flexible.
There are a couple of gotchas in writing datetime constants in SQL
commands. You have to put quotes around them (they're strings as
far as the parser is concerned). For example,
select * from ohistory where ordertime < 'jun 10 1998 16:00';
In some situations you may have to explicitly cast the string constant
to datetime type:
select * from ohistory where ordertime < 'jun 10 1998 16:00'::datetime;
but I find Postgres usually manages to figure out for itself that a
datetime value is wanted.
As far as I know those gotchas also apply to date constants, however.
So I'm still confused about why one works and not the other for you.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, ericm@palaver.net, pgsql-sql@hub.org
Subject: Re: date versus datetime?
In-Reply-To: <18511.902002588@sss.pgh.pa.us>
References: <199808010332.XAA14257@hub.org> <18511.902002588@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox