From: Thomas F.O'Connell <tfo@sitening.com>
To: Nick Peters <nick.peters@candoltd.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Comparing Dates
Date: Thu, 18 Nov 2004 15:15:30 -0600
Message-ID: <FA0F2254-39A6-11D9-95C2-000D93AE0944@sitening.com> (raw)
In-Reply-To: <419D0DC6.5080504@candoltd.com>
References: <419D0DC6.5080504@candoltd.com>
Nick,
You need to quote your date constant value:
'2004-06-08'
select '2004-06-08'::date > 2004-06-08;
?column?
----------
t
(1 row)
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.
-tfo
--
Thomas F. O'Connell
Co-Founder, Information Architect
Sitening, LLC
http://www.sitening.com/
110 30th Avenue North, Suite 6
Nashville, TN 37203-6320
615-260-0005
On Nov 18, 2004, at 3:01 PM, Nick Peters wrote:
> Hey,
>
> I am trying to compare dates in a sql statement. this is what i have
> tried:
>
> SELECT * FROM transactions WHERE shippingdate>2004-06-08 AND
> transtype='Sale';
>
> but it returns all rows. When i switch the > with a < it returns
> nothing. I have even tried with todays date and have got the same
> results. So i guess my question is how do i compare two dates? BTW the
> column by the name of shippingdate is a date data type with the same
> format as the dates show above.
>
> Thanks in advance.
>
> -Nick
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to
> majordomo@postgresql.org
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: tfo@sitening.com, nick.peters@candoltd.com
Subject: Re: Comparing Dates
In-Reply-To: <FA0F2254-39A6-11D9-95C2-000D93AE0944@sitening.com>
References: <419D0DC6.5080504@candoltd.com> <FA0F2254-39A6-11D9-95C2-000D93AE0944@sitening.com>
* 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