sql - 通过给定的 SLA 时间范围和营业时间计算到期日期时间的 SQL 函数
问题描述
我需要帮助来创建一个能够计算业务运营时间内给定 SLA 时间范围(小时)的截止日期的函数
在这里找到可能的解决方案:使用营业时间和假期计算截止日期,但我无法将建议转换为函数。
功能: fn_GetDueDate (@SLAStart datetime, @SLATarget int)
- SLA 开始时间/请求接收时间 = 日期时间字段 SLA 开始日期
- SLA 时间范围 = 以小时为单位的 SLA
用于计算 DueDate 的变量:
Business Start time (weekday) = 8am
Business End time (weekday) = 9pm
Business Start time (weekends & some public holidays) = 10am
Business Start time (weekends & some public holidays) = 5pm
我有一个带有日期和描述的假期表,如果需要,我可以添加列
预期结果:
1. IF
@SLAStart = 2021-08-13 19:30:00.000 (friday, 7:30 PM - operations 8am-9pm)
@SLATarget = 3 hours
fn_GetDueDate RETURNS = 2021-08-14 10:00:00.000 (saturday, 11:30 AM - operations 10am-5pm)
2. @SLAStart = 2021-08-15 15:57:00.000 (saturday, 3:57 PM - operations 10am-5pm)
@SLATarget = 2 hours
fn_GetDueDate RETURNS = 2021-08-16 08:57:00.000 (monday, 08:57 AM - operations 8am-9pm)
解决方案
推荐阅读
- r - 组合多个大序列的所有元素
- apache-spark - Spark 错误 java.lang.NoSuchFieldError: SPARK_RPC_SERVER_ADDRESS 上的 Hive
- makefile - 基于目录存在的 Makefile 变量分配
- python-3.x - 如何在 AWS SageMaker(Jupyter Notebook)中使用 cx_Oracle
- android - Observable subscribe 没有被调用相同的值
- java - 单元测试仅更新某些属性的方法
- python - 通过计算0在python中groupby之后的列中出现的次数来实现子集
- laravel - 如何对两列进行验证
- macos - macOS 中的应用程序拦截器 1Focus 如何阻止(最小化)其他应用程序?
- java - 如何在构造函数中访问 application.properties 值