pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: novice <user.postgresql@gmail.com>
To: pgsql-general@postgresql.org
To: pgsql-sql@postgresql.org
Subject: work hour calculations
Date: Wed, 5 Sep 2007 13:45:46 +1000
Message-ID: <ddcb1c340709042045lbe5d58fode7497c8eb060c97@mail.gmail.com> (raw)

Hello All,

SELECT notification_time, finished_time, sum(finished_time -
notification_time) as actual
FROM log
GROUP BY notification_time, finished_time;

gives me:

   notification_time    |     finished_time      |     actual
------------------------+------------------------+-----------------
 2007-07-06 15:50:00+10 | 2007-07-09 07:10:00+10 | 2 days 15:20:00
 2007-07-07 12:30:00+10 | 2007-07-09 07:20:00+10 | 1 day 18:50:00


How can write a query to calculate the duration using custom work
hours which is Monday 7am /  Friday 5pm?

The result I'm expecting for the above to be

   notification_time    |     finished_time      |     actual
------------------------+------------------------+-----------------
 2007-07-06 15:50:00+10 | 2007-07-09 07:10:00+10 | 00:20:00
 2007-07-07 12:30:00+10 | 2007-07-09 07:20:00+10 | 00:20:00

Thanks.



view thread (7+ messages)  latest in thread

Message-ID: <ddcb1c340709042045lbe5d58fode7497c8eb060c97@mail.gmail.com>
Permalink:  ../ddcb1c340709042045lbe5d58fode7497c8eb060c97@mail.gmail.com/
Also on:    postgresql.org/message-id/ddcb1c340709042045lbe5d58fode7497c8eb060c97@mail.gmail.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: user.postgresql@gmail.com, pgsql-general@postgresql.org
  Subject: Re: work hour calculations
  In-Reply-To: <ddcb1c340709042045lbe5d58fode7497c8eb060c97@mail.gmail.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