在mysql select query中需要建议。
圈子工作时间:9AM to 6PM
案例1:
If ticket was assigned to circle at 5 pm on Day 1
and was closed by circle at 11 am on Day 2,
then time diff should be 3 hrs.
案例2:
If a ticket is assigned at 7 pm on Day1,
then timediff will only start from 9 am on Day 2
案例3:
If ticket is escalated on a Sunday,
then it's timediff will start from 9 am on Monday
答案 0 :(得分:0)
您可以引入自己的日历,仅计算从某个固定日期开始的工作秒数。 然后,您可以像使用正常时间戳一样进行计算,并获得"工作秒数"两个时间戳之间。
您需要一层逻辑,将实际日期转换为"工作秒数"。
您需要决定是否 a)第1天,18:00h =第2天,09:00h 要么 b)第1天,18:00h + 1 =第2天,09:00h
让我们使用a)作为例子:
案例1:
Ticket is assigned at Timestamp = 8 * 60 (8 hours since the start of time)
Ticket is closed at Timestamp = 11 * 60
time diff = 11*60 - 8*60 = 3*60
案例2:
Ticket is assigned at Timestamp = 0 (would have to be convertd before going to db)
Ticket age is current Timestamp
使用每年(/月/日)的表格转换点可以加速转化