你这个挺麻烦的,在ds的sql里面处理吧
with AA as (
select cast('2024-04-15 08:30:00' as datetime) sdate,cast('2024-04-15 09:00:00' as datetime) edate
union all select cast('2024-04-15 08:30:00' as datetime) sdate,cast('2024-04-15 09:30:00' as datetime) edate
union all select cast('2024-04-15 08:30:00' as datetime) sdate,cast('2024-04-15 11:00:00' as datetime) edate
union all select cast('2024-04-15 08:30:00' as datetime) sdate,cast('2024-04-15 12:00:00' as datetime) edate
union all select cast('2024-04-15 08:30:00' as datetime) sdate,cast('2024-04-15 13:00:00' as datetime) edate
union all select cast('2024-04-15 08:30:00' as datetime) sdate,cast('2024-04-15 14:00:00' as datetime) edate
union all select cast('2024-04-15 08:30:00' as datetime) sdate,cast('2024-04-15 17:00:00' as datetime) edate
union all select cast('2024-04-15 08:30:00' as datetime) sdate,cast('2024-04-15 19:00:00' as datetime) edate
)
select *,(amMinute+(case when pmMinute >=240 then 240 else pmMinute end))*1.000/60/7.5 workdaynum from (
select *,
case when edate>=(CONVERT(varchar(20),sdate,23) +' 12:00:00')
then DATEDIFF(minute, sdate, CONVERT(varchar(20),sdate,23)+' 12:00:00')
else DATEDIFF(minute, sdate, edate) end amMinute,
case when edate>=(CONVERT(varchar(20),sdate,23) +' 13:00:00')
then DATEDIFF(minute, CONVERT(varchar(20),sdate,23)+' 13:00:00', edate)
else 0 end pmMinute
from AA ) s