Res: sum timestamp result in hours

From: paulo matadr <saddoness(at)yahoo(dot)com(dot)br>
To: Sql-listas_post <pgsql-sql(at)postgresql(dot)org>
Cc: Osvaldo Kussama <osvaldo(dot)kussama(at)gmail(dot)com>
Subject: Res: sum timestamp result in hours
Date: 2008-11-07 16:36:01
Message-ID: 658284.65384.qm@web52502.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I change form to create query but basically need
sum(rgat.rgat_tmencerramento - rgat.rgat_tmregistroatendimento) = result in hours

sumary:
rgat.rgat_tmencerrament = timestamp column
gat.rgat_tmregistroatendimento = timestamp column

________________________________
De: Osvaldo Kussama <osvaldo(dot)kussama(at)gmail(dot)com>
Para: paulo matadr <saddoness(at)yahoo(dot)com(dot)br>
Enviadas: Sexta-feira, 7 de Novembro de 2008 12:50:14
Assunto: Re: [SQL] sum timestamp result in hours

2008/11/7, paulo matadr <saddoness(at)yahoo(dot)com(dot)br>:
> Select sum(age(rgat.rgat_tmencerramento, rgat.rgat_tmregistroatendimento))
> from atendimentopublico.registro_atendimento rgat
> inner join cadastro.localidade loca on loca.loca_id=rgat.loca_id
> inner join atendimentopublico.solicitacao_tipo_especificacao step on
> step.step_id=rgat.step_id
> where
> date(rgat_tmregistroatendimento) between '2007-01-01' and '2007-12-31'
> and rgat.step_id in
> (706,710,717,718,719,722,725,728,730,732,733,720,721,727,714,729)
> and rgat.rgat_cdsituacao=2
> and date(rgat_tmencerramento) between '2007-01-01' and '2007-12-31'
> and rgat.rgat_tmencerramento > rgat.rgat_tmregistroatendimento
> and rgat.loca_id=339
> and rgat.rgat_id in
> (20111305,
> 30102409,
> 30102096,
> 30097214,
> 30102396,
> 20057815,
> 20325895)
> Result: 1 year 4 mons 88 days 51:42:00
>
> I need help to view result query only in hours, the timestamp columns in
> bold above.
>

88 days? 51 hours?

Try:
bdteste=# SELECT EXTRACT(EPOCH FROM INTERVAL '1 year 4 mons 88 days
51:42:00')/3600;
?column?
----------
13809.7
(1 registro)

Osvaldo

Novos endereços, o Yahoo! que você conhece. Crie um email novo com a sua cara @ymail.com ou @rocketmail.com.
http://br.new.mail.yahoo.com/addresses

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2008-11-07 16:49:44 Re: sum timestamp result in hours
Previous Message paulo matadr 2008-11-07 14:20:29 sum timestamp result in hours