work hour calculations

Поиск
Список
Период
Сортировка
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.

В списке pgsql-sql по дате отправления: