Re: interval and timestamp change?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris Ruprecht <chrup999(at)yahoo(dot)com>
Cc: "postgresql" <pgsql(at)symcom(dot)com>, "PgSQL-SQL" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: interval and timestamp change?
Date: 2002-01-27 04:07:35
Message-ID: 25930.1012104455@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Chris Ruprecht <chrup999(at)yahoo(dot)com> writes:
> Here is Tom's explanation from that time:
> TIME is a reserved word now, or at least more reserved than it used to
> be. You'll need to write 'now'::time or CAST('now' AS time). Sorry
> about that, but SQL92 requires it...

Actually there's nothing wrong with his 'now', though as Brent points
out CURRENT_TIMESTAMP would be more standards-compliant. The real
problem is that INTERVAL is also a more-reserved word than it used to
be. So instead of

SELECT interval(('1/30/02 12:30 pm'::timestamp) - 'now');
ERROR: parser: parse error at or near "("

he needs

SELECT "interval"(('1/30/02 12:30 pm'::timestamp) - 'now');

or

SELECT (('1/30/02 12:30 pm'::timestamp) - 'now')::interval;

although since the difference of two timestamps is already an interval,
there's not really any need for the cast anyway. So this is sufficient:

SELECT '1/30/02 12:30 pm'::timestamp - current_timestamp;

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2002-01-27 04:19:21 Re: LIMIT Optimization
Previous Message pgsql 2002-01-27 04:04:48 options for no multiple rows?