我使用PostgreSQL,我想在纯SQL 中计算没有星期日的工作时间。
结果需要分钟。
数据例如:
begin_date, end_date
2016-12-30 08:58:31,2016-12-31 15:28:22
2016-11-24 15:36:41,2016-11-30 16:35:23
2016-06-04 12:49:22,2016-06-30 15:12:28
我需要一个输出:12200(分钟数)
begin_date, end_date, minute_worked
2016-12-30 09:00:00,2016-12-31 18:00:00, 960
星期一至星期六工作日为9至18(上午9点至晚上8点)(除周日外) 我可能需要这样做:
(Hour of first day) + (hour of last day) + (day worked * 8 * 60) //Multiply by 8 for the 8 hour work per day and by 60 in order to have the result in minute.