Division of intervals.

From: Joshua Moore-Oliva <josh(at)chatgris(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Division of intervals.
Date: 2003-03-19 00:32:48
Message-ID: 200303181932.48369.josh@chatgris.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Attempting rather unsuccessfully to convert something of the form

45 years 9 mons 5 days 20:28:18.886891

to a total number of months, 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'
You will have to retype this query using an explicit cast

Does anyone know what interval format intervals are stored as? Is there a way
I can cast this expression to be able to find the number of months within
this interval?

Or is there a function I don't know about capable of doing this? (extracting
the total number of a specific interval from another interval)... e.g. total
number of months, total number of days...

Josh.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-03-19 00:47:58 Re: Referential Integrity problem
Previous Message Josh Berkus 2003-03-19 00:21:43 Limitations in PL/perl