extract or date_part on an interval? How many e

Поиск
Список
Период
Сортировка
От Bryce Nesbitt
Тема extract or date_part on an interval? How many e
Дата
Msg-id 479D3E63.2080601@obviously.com
обсуждение исходный текст
Ответы Re: extract or date_part on an interval? How many e  (Adrian Klaver <aklaver@comcast.net>)
Re: extract or date_part on an interval? How many e  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Hmm.  Seemed so simple.  But how do I get the number of years an
interval represents?  extract is clearly the wrong way:

stage=# select 'now()-'1987-02-01' as interval,extract(year from
now()-'1987-02-01') as age;       interval          | age
--------------------------+-----
7665 days 18:05:51.660345 |   0

select EXTRACT(year FROM INTERVAL '7665 days'); gives the same result.

select EXTRACT(day FROM now()-'1987-02-01')/365 as age; seems messy.
select (now()-'1987-02-01')/365; gives extraneous junk.
Thanks!

-- 
----
Visit http://www.obviously.com/




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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Syntax question: use of join/using with fully qualified table name
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: extract or date_part on an interval? How many e