Re: Interval subtracting

Поиск
Список
Период
Сортировка
Искать
От
Milorad Poluga
Тема
Re: Interval subtracting
Дата
Msg-id
200602181536.20605.milorad.poluga@cores.co.yu
Ответ на
Re: Interval subtracting (Milen A. Radev)
Список
Дерево обсуждения
Interval subtracting Milorad Poluga <milorad.poluga@cores.co.yu>
Re: Interval subtracting "Milen A. Radev" <milen@radev.net>
Re: Interval subtracting Milorad Poluga <milorad.poluga@cores.co.yu>
Re: Interval subtracting "Milen A. Radev" <milen@radev.net>
Re: Interval subtracting Tom Lane <tgl@sss.pgh.pa.us>
Re: Interval subtracting Stephan Szabo <sszabo@megazone.bigpanda.com>
Re: Interval subtracting Bruce Momjian <pgman@candle.pha.pa.us>
Re: Interval subtracting Scott Marlowe <smarlowe@g2switchworks.com>
Re: [HACKERS] Interval subtracting Bruce Momjian <pgman@candle.pha.pa.us>
Re: [HACKERS] Interval subtracting Scott Marlowe <smarlowe@g2switchworks.com>
Re: [HACKERS] Interval subtracting Markus Schaber <schabi@logix-tt.com>
Re: [HACKERS] Interval subtracting Scott Marlowe <smarlowe@g2switchworks.com>
Re: [HACKERS] Interval subtracting Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] Interval subtracting PFC <lists@peufeu.com>
Re: Interval subtracting Milorad Poluga <milorad.poluga@cores.co.yu>
On Saturday 18 February 2006 15:24, Milen A. Radev wrote:
> Milorad Poluga написа:
> > Hi all,
> > 
> > Is there something incorrect in the above query ? 
> > SELECT '10 years 1 mons 1 days'::interval - '9 years 10 mons 15 days'::interval
> > 
> >  ?column?        
> >  --------------- 
> >  3 mons -14 days 
> > 
> > Why not '2 mons  16 days' ? 
> > 
> > /version =  PostgreSQL 8.0.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) /
> 
> 
> How many days are there in a month?
> 

I beleive that a month is calculated on the 30-days base.

One way to solve this problem is to use a neutal date element and make timestamps :

SELECT age(('1990-01-01'::date + '10 years 1 mons 1 days'::interval)::timestamp ,    ('1990-01-01'::date + '9 years 10 mons 15 days'::interval)::timestamp)
age            -------------- 2 mons 16 days 

Regards, 
Milorad Poluga

---------------------------------------
milorad.poluga@cores.co.yu
---------------------------------------


В списке pgsql-sql по дате отправления
От: Milen A. Radev
Дата:
Сообщение: Re: Interval subtracting
От: Milen A. Radev
Дата:
Сообщение: Re: Interval subtracting
FAQ