Re: Can't EXTRACT number of months from an INTERVAL

From: "Eliot, Christopher" <christopher(dot)eliot(at)nagrastar(dot)com>
To: Michael Glaesemann <grzm(at)seespotcode(dot)net>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Can't EXTRACT number of months from an INTERVAL
Date: 2010-07-01 16:10:10
Message-ID: EDF9B887785F8A47B7F96D70AD69D91001147F181E@nstar-server7
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks! justify_interval is what I needed, I had never heard of it. I was already prepared to deal with getting the years and multiplying by 12.

Topher
[]

On Jun 30, 2010, at 18:45 , Eliot, Christopher wrote:

> I need to read a timestamp from the database and turn that into an integer describing how many months ago the event happened, rounding downward. The events are guaranteed to be in the past.

=# select timestamp '2010-06-26 00:00:00' - timestamp '2008-11-07 00:00:00';
?column?
----------
596 days
(1 row)

=# select justify_interval(timestamp '2010-06-26 00:00:00' - timestamp '2008-11-07 00:00:00');
justify_interval

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mike Christensen 2010-07-01 16:31:12 Re: Easy way to convert a database from WIN1252 to UTF8?
Previous Message Mike Christensen 2010-07-01 16:08:55 Easy way to convert a database from WIN1252 to UTF8?