Re: Using DateDiff with Postgres

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Using DateDiff with Postgres
Дата
Msg-id 003501c0ffe0$dc3e4700$1001a8c0@archonet.com
обсуждение исходный текст
Ответ на Using DateDiff with Postgres  (jeff@emojo.com (Jeff Rhys-Jones))
Список pgsql-sql
From: "Jeff Rhys-Jones" <jeff@emojo.com>

> 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.
>
> I've looked at postgres.org and can't seem to find any ref. to using
> datediff.

You just subtract dates with PG:

select now() - CURRENT_DATE;

Will return an "interval" type with the elapsed time since midnight. If you
want that in seconds do:

select extract(epoch from (now() - CURRENT_DATE));

Converting to minutes is obviously easy from there.

I think datediff() is a MS-Access thing isn't it?

- Richard Huxton




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

Предыдущее
От: Christof Glaser
Дата:
Сообщение: Re: Link many attributes in one table to one attribute in another??
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: filtering