Skip site navigation (1) Skip section navigation (2)

Re: consistant output for type interval

From: Dorin Grunberg <dorin(at)visgen(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: consistant output for type interval
Date: 2001-07-16 15:48:33
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Sorry, I did some research and I came with this solution:

SELECT extract(day from sum(my_co))*24 + lpad(extract(hour from 
sum(my_co)), 2, '0')||':'||lpad(extract(minute from sum(my_co)), 2, '0') 
FROM tr;


At 11:09 AM 7/16/01 -0400, Dorin Grunberg wrote:
>I have a table where one of the columns is of type interval.
>When I calculate the sum of that column the results are looking like this:
>1 day 5:30
>1 day
>I would like to have it consistent in the HH:MM format and, if it is not 
>possible this way, perhaps something like:
>1 day 05:30
>1 day 00:00
>0 day 05:45
>I know I can manipulate the results on the Perl or PHP side but I thought 
>that there might be another way.
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster

In response to

pgsql-novice by date

Next:From: Henry HouseDate: 2001-07-16 15:53:07
Subject: Re: GROUP BY and aggregate functions
Previous:From: Dorin GrunbergDate: 2001-07-16 15:09:35
Subject: consistant output for type interval

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group