Re: is in postgres solution - Mailing list pgsql-general

From Ragnar Hafstað
Subject Re: is in postgres solution
Date
Msg-id 1116274200.8646.9.camel@localhost.localdomain
Whole thread Raw
In response to is in postgres solution  (Margus Roo <margusja@101d.ee>)
List pgsql-general
On Mon, 2005-05-16 at 11:43 +0300, Margus Roo wrote:
> Hello.
> I have 2 variables type timestamp. Example date1 = 2005-01-01 23:00 and
> date2 = 2005-05-04 12:00. I want get something like age(date2,date1) but
> ouput format must by hours::minutes.

get the difference in minutes with:
  extract('epoch' from date2-date1) / 60
and do the formatting with / and %

or

select extract('epoch' from date2-date1)/3600
       || '::'
       || extract('minutes' from date2-date1);

gnari



pgsql-general by date:

Previous
From: Adam Witney
Date:
Subject: Re: Distinguishing between connections in pg_hba.conf
Next
From: Scott Marlowe
Date:
Subject: Re: Distinguishing between connections in pg_hba.conf