pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aarni Ruuhimäki <aarni@kymi.com>
To: Jan Muszynski <postgres@jancm.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: interval as hours or minutes ?
Date: Thu, 8 Feb 2007 12:01:18 +0200
Message-ID: <200702081201.18645.aarni@kymi.com> (raw)
In-Reply-To: <45CA07D5.9647.29301B0@postgres.jancm.org>
References: <200702071903.35126.aarni@kymi.com>
	<45CA07D5.9647.29301B0@postgres.jancm.org>

On Thursday 08 February 2007 00:09, you wrote:
> select extract(epoch from (timestamp '2007-02-07 16:24:00' - timestamp
> '2007-02-05 13:00:01'))/60 as minutes;
>
>      minutes
> ------------------
>  3083.98333333333
> (1 row)
>
> select round(extract(epoch from (timestamp '2007-02-07 16:24:00' -
> timestamp '2007-02-05 13:00:01'))/60) as minutes;
>
>  minutes
> ---------
>     3084
> (1 row)

Hi Guys,

Charming !

Furher still, I would only want full minutes.

select extract(epoch from (SELECT SUM(stop_date_time - start_date_time) FROM 
work_times WHERE user_id = 10 AND start_date_time >= '2007-01-01' AND 
stop_date_time <= '2007-02-28')/60) as mins;
    mins
-------------
 3728.733333
(1 row)

select convert_interval((SELECT SUM(stop_date_time - start_date_time) FROM 
work_times WHERE user_id = 10 AND start_date_time >= '2007-01-01' AND 
stop_date_time <= '2007-02-28'),'minutes') as minutes;
         minutes
--------------------------
 3728.73333333333 minutes
(1 row)

select round(extract(epoch from (SELECT SUM(stop_date_time - start_date_time) 
FROM work_times WHERE user_id = 10))/60) as mins;
 mins
------
 3729
(1 row)

So instead of rounding up to 3729 the result would have to be 'stripped' to 
3728 ?

Thanks,


-- 
Aarni Ruuhimäki



view thread (8+ messages)  latest in thread

Message-ID: <200702081201.18645.aarni@kymi.com>
Permalink:  ../200702081201.18645.aarni@kymi.com/
Also on:    postgresql.org/message-id/200702081201.18645.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, postgres@jancm.org
  Subject: Re: interval as hours or minutes ?
  In-Reply-To: <200702081201.18645.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