Doing INTERVAL with NOW() versus casted timestamp

From: Wells Oliver <wellsoliver(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Doing INTERVAL with NOW() versus casted timestamp
Date: 2013-02-16 15:25:10
Message-ID: CAOC+FBV8UM0YqAfYCu5d6RLBTmhsa5cErcJt4yg8wbN=uMQn1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Why does this give me two different results? 'created' is a date field:

SELECT * FROM foo WHERE created >= '2013-02-16 00:00:00'::timestamp -
INTERVAL '24 hours'

and

SELECT * FROM foo WHERE created >= NOW() - INTERVAL '24 hours'

First returns the 12 rows I expect where the 'created' field is 2012-02-15,
second returns only one.

Thank you.

--
Wells Oliver
wellsoliver(at)gmail(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2013-02-16 15:41:58 Re: Doing INTERVAL with NOW() versus casted timestamp
Previous Message David Kerr 2013-02-16 06:21:14 Re: PG9.2.3. Query hanging: SELECT count(*) FROM pg_catalog.pg_class...