Re: [HACKERS] date/time problem in v6.5.3 and 7.0.0 ...

From: Jose Soares <jose(at)sferacarta(dot)com>
To: The Hermit Hacker <scrappy(at)hub(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] date/time problem in v6.5.3 and 7.0.0 ...
Date: 2000-01-18 14:10:58
Message-ID: 38847472.DC3C84AA@sferacarta.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The Hermit Hacker wrote:

> I can add days to now(), but not subtract?
>
> =====================================
>
> template1=> select now() + '30 days';
> ?column?
> ------------------------------
> Sun Feb 13 22:00:33 2000 AST
> (1 row)
>
> template1=> select now() - '30 days';
> ERROR: Unable to identify an operator '-' for types 'timestamp' and 'unknown'
> You will have to retype this query using an explicit cast
> template1=> select version();
> version
> ---------------------------------------------------------------------
> PostgreSQL 7.0.0 on i386-unknown-freebsd4.0, compiled by gcc 2.95.2
> (1 row)
>
> Marc G. Fournier ICQ#7615664 IRC Nick: Scrappy
> Systems Administrator @ hub.org
> primary: scrappy(at)hub(dot)org secondary: scrappy(at){freebsd|postgresql}.org
>
> ************

Try using standard names (TIMESTAMP instead of now() and INTERVA) as in:

hygea=> select current_timestamp + interval '30 day';
?column?
--------------------------
17/02/2000 16:00:28.00 CET
(1 row)

hygea=> select current_timestamp - interval '30 day';
?column?
--------------------------
19/12/1999 16:00:44.00 CET
(1 row)

hygea=> select now() - '30 day';
ERROR: Unable to identify an operator '-' for types 'timestamp' and 'unknown'
You will have to retype this query using an explicit cast

José

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 2000-01-18 14:40:27 Re: [HACKERS] date/time problem in v6.5.3 and 7.0.0 ...
Previous Message Tatsuo Ishii 2000-01-18 14:01:30 Re: [HACKERS] Cannot compile psql