Re: interval and timestamp change?
| От | Tom Lane |
|---|---|
| Тема | Re: interval and timestamp change? |
| Дата | |
| Msg-id | 25930.1012104455@sss.pgh.pa.us обсуждение |
| Ответ на | Re: interval and timestamp change? (Chris Ruprecht <chrup999@yahoo.com>) |
| Список | pgsql-sql |
Chris Ruprecht <chrup999@yahoo.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
В списке pgsql-sql по дате отправления: