Re: [SQL] now() returning int4

From: "Ross J(dot) Reedstrom" <reedstrm(at)wallace(dot)ece(dot)rice(dot)edu>
To: Marc Tardif <admin(at)wtbwts(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] now() returning int4
Date: 2000-01-31 22:28:40
Message-ID: 20000131162840.A5157@rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, Jan 31, 2000 at 04:59:19PM +0000, Marc Tardif wrote:
> I have a table containing an integer field defaulting to now(), which I
> want to use as the unix timestamp counting the seconds from jan 1 1970.
> Problem is when I try to perform queries using now():
>
> db=> CREATE TABLE test (
> db-> date int default now()
> db-> );
> CREATE
> db=> SELECT * FROM test WHERE date < now();
> ERROR: Unable to identify operator '<' for types 'int4' and 'timestamp'
> You will have to retype this query using an explicit cast
> db=> SELECT * FROM test WHERE date::timestamp < now();
> bis
> db=> SELECT * FROM test WHERE date < now()::int4;
> bis
>

SELECT * FROM test WHERE date < int(now());

Works here.

Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ray Plante 2000-01-31 23:03:38 GROUP BY: v6.1 vs. v6.5.2
Previous Message Marc Tardif 2000-01-31 16:59:19 now() returning int4