Re: Changes to NOW() in 7.2? - Mailing list pgsql-general

From Tom Lane
Subject Re: Changes to NOW() in 7.2?
Date
Msg-id 9217.1015284126@sss.pgh.pa.us
Whole thread Raw
In response to Changes to NOW() in 7.2?  (Hunter Hillegas <lists@lastonepicked.com>)
List pgsql-general
Hunter Hillegas <lists@lastonepicked.com> writes:
> I have a query like this:
> SELECT tour_dates.date, WHERE date_of_show >= NOW() ORDER BY date_of_show;
> On 7.1.3, this query would include the current day as well as all dates in
> the future. Since moving to 7.2, it only includes dates in the
> future...

I don't believe it worked like that in 7.1.3 either --- at least not if
date_of_show is of type date.  NOW() is generally going to be later than
midnight, which is what a date promotes to when you compare it to a
timestamp.

test71=# select version();
                             version
------------------------------------------------------------------
 PostgreSQL 7.1.3 on hppa2.0-hp-hpux10.20, compiled by GCC 2.95.3
(1 row)

test71=# create table foo (date_of_show date);
CREATE
test71=# insert into foo values ('today');
INSERT 1602743 1
test71=# select * from foo;
 date_of_show
--------------
 2002-03-04
(1 row)

test71=# select * from foo where date_of_show >= NOW();
 date_of_show
--------------
(0 rows)

What you probably want is CURRENT_DATE:

test71=# select * from foo where date_of_show >= current_date;
 date_of_show
--------------
 2002-03-04
(1 row)

            regards, tom lane

pgsql-general by date:

Previous
From: Steve Atkins
Date:
Subject: Fast, indexed bulk inserts
Next
From: missive@frontiernet.net (Lee Harr)
Date:
Subject: Re: Migration problem - serial fields