Re: Division of intervals.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joshua Moore-Oliva <josh(at)chatgris(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Division of intervals.
Date: 2003-03-19 05:23:16
Message-ID: 4194.1048051396@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Joshua Moore-Oliva <josh(at)chatgris(dot)com> writes:
> I attempted
> SELECT age(now(), timestamp '1957-06-13') / interval '1 month';
> and got the error
> ERROR: Unable to identify an operator '/' for types 'interval' and 'interval'

I'm not sure division of intervals is sensible --- consider the
recently-pointed-out issues about variable length of months, etc.

Does this do what you want?

regression=# SELECT extract(year from age(now(), timestamp '1957-06-13'));
date_part
-----------
45
(1 row)

regression=# SELECT extract(month from age(now(), timestamp '1957-06-13'));
date_part
-----------
9
(1 row)

regression=# SELECT extract(year from age(now(), timestamp '1957-06-13')) *12
regression-# + extract(month from age(now(), timestamp '1957-06-13'));
?column?
----------
549
(1 row)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2003-03-19 05:24:36 Re: Limitations in PL/perl
Previous Message Josh Berkus 2003-03-19 05:17:12 Re: Limitations in PL/perl