Re: Age function

Поиск
Список
Период
Сортировка
От Alexander Staubo
Тема Re: Age function
Дата
Msg-id 88daf38c0705141304t7c37e8f0xdfce3ec5280cb2f1@mail.gmail.com
обсуждение исходный текст
Ответ на Age function  ("Andrus" <kobruleht2@hot.ee>)
Список pgsql-general
On 5/14/07, Andrus <kobruleht2@hot.ee> wrote:
> How to create function which returns persons age in years?
[snip]

What's wrong with age()?

# select age('1879-03-14'::date);
       age
------------------
 128 years 2 mons
# select extract(year from age('1879-03-14'::date));
 date_part
-----------
       128

You can give age() two arguments to calculate the difference between
two dates to get an interval:

# select age('1955-04-18'::date, '1879-03-14'::date);
          age
-----------------------
 76 years 1 mon 4 days

If you subtract two date values you will get the number of days
instead of an interval.

Documentation:

  http://www.postgresql.org/docs/8.2/interactive/functions-datetime.html

Alexander.

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

Предыдущее
От: "Andrus"
Дата:
Сообщение: How to implement GOMONTH function
Следующее
От: Jon Sime
Дата:
Сообщение: Re: Age function