pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aarni Ruuhimäki <aarni@kymi.com>
To: pgsql-sql@postgresql.org
Subject: interval as hours or minutes ?
Date: Wed, 7 Feb 2007 19:03:35 +0200
Message-ID: <200702071903.35126.aarni@kymi.com> (raw)

Hi all,

Could anyone please tell an easy way to get total hours or minutes from an 
interval ?

SELECT SUM(stop_date_time - start_date_time) AS tot_time FROM work_times WHERE 
user_id = 1;
    tot_time
-----------------
 2 days 14:08:44

I'd like to have this like ... AS tot_hours ...
    tot_hours
-----------------
62

and ... AS tot_minutes ...
    tot_minutes
-----------------
3728

Maybe even ... AS tot_hours_minutes_seconds
    tot_hours_minutes_seconds
-----------------
62:08:44


start_date_time and stop_date_time are stored as timestamp without time zone, 
using Pg 8.1.5 on CentOs 4.4

???

Thanks,

-- 
Aarni Ruuhimäki




view thread (8+ messages)  latest in thread

Message-ID: <200702071903.35126.aarni@kymi.com>
Permalink:  ../200702071903.35126.aarni@kymi.com/
Also on:    postgresql.org/message-id/200702071903.35126.aarni@kymi.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: aarni@kymi.com
  Subject: Re: interval as hours or minutes ?
  In-Reply-To: <200702071903.35126.aarni@kymi.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox