Skip site navigation (1) Skip section navigation (2)

now() returning int4

From: Marc Tardif <admin(at)wtbwts(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: now() returning int4
Date: 2000-01-31 16:59:19
Message-ID: (view raw or whole thread)
Lists: pgsql-sql
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-> );
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();
db=> SELECT * FROM test WHERE date < now()::int4;

Please let me know how I can get this to work properly, I'm using
postgresql 6.5.3.



pgsql-sql by date

Next:From: Ross J. ReedstromDate: 2000-01-31 22:28:40
Subject: Re: [SQL] now() returning int4
Previous:From: Peter EisentrautDate: 2000-01-31 12:21:27
Subject: Re: [SQL] inet/cidr - can this be done?

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group