Re: Using DateDiff with Postgres

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Using DateDiff with Postgres
Дата
Msg-id web-78658@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на Using DateDiff with Postgres  (jeff@emojo.com (Jeff Rhys-Jones))
Список pgsql-sql
Bruce, Tom, Etc:
This question comes up so often. Can't we have a FAQ about it
somewhere?

Jeff,

> Hi there. I was wondering if anyone can tell me the correct syntax
> for
> using DateDiff for postgrees. I'm using MI (or mi) for minute and I
> keep getting attribute 'mi' not found.

Datediff is not a SQL function. It is a MICROSOFT function, due to MS's
poor implementation of data types.

In PostgreSQL, you simply add and subtract interval values to datetime
values:

'2001-06-27 14:43:21'::DATETIME - '00:10:00'::INTERVAL = '2001-06-27
14:33:21'::DATETIME


'2001-06-27 14:43:21'::DATETIME - '2001-06-27 14:33:21'::DATETIME =
'00:10:00'::INTERVAL

For more information, see "Functions and Operators" in the PostgreSQL
online docs.

-Josh Berkus


______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco
 


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Ross J. Reedstrom"
Дата:
Сообщение: Re: Subquery error. Help please!!
Следующее
От: Phuong Ma
Дата:
Сообщение: restoring a dump