我有一个显示订单周转时间的 MS Access 查询。两个问题:
- 时间是 24 小时制时间(例如:0105),因此当您从 CPOE 时间中减去验证时间时,您会得到一个既不是分钟也不是小时的值,因此您不能简单地将其转换为分钟(即: 0701 – 0527 = 174, 实际相差 94 分钟),
- 如果 CPOE 时间在午夜之前,而验证时间在午夜之后,则差异非常扭曲(即:2351 – 0024 = 2327,实际差异为 33 分钟)。
有谁知道如何解决这个问题?这是 SQL 查询:
SELECT
BI.PTNAME,
PHM_POE_HIST.FUNCTION,
PHM_ORDERS.VALIDATED_DATE,
PHM_ORDERS.VALIDATED_BY,
SAT.USER_NAME,
PHM_ORDERS.VALIDATED_TIME,
Right([TRAN_DATE_TIME],4) AS CPOE_TIME,
Abs([validated_time]-[CPOE_TIME]) AS Diff,
PHM_POE_HIST.TRAN_DATE_TIME,
PHM_POE_HIST.EFF_DATE_TIME,
PHM_POE_HIST.HIST_SEQ, BI.NRS_STATION,
SITE.NAME, PHM_ORDERS.PMP,
PHM_ORDERS.PRIORITY,
Trim([GENERIC_NAME] & " " & [STRENGTH] & " " & [STRENGTH_UNIT] & " " & [DOSAGE_FORM] & " " & [LATIN_DIR_ABBR]) AS DESCRIPTION
FROM
((BI LEFT JOIN
(PHM_ORDERS LEFT JOIN PHM_POE_HIST ON (PHM_ORDERS.POE_ORDER_NUMBER = PHM_POE_HIST.POE_ORDER_NUMBER) AND (PHM_ORDERS.ITN = PHM_POE_HIST.ITN))
ON BI.ITN = PHM_ORDERS.ITN)
LEFT JOIN SAT
ON PHM_ORDERS.VALIDATED_BY = SAT.USER_INITIALS)
LEFT JOIN SITE
ON BI.SITE = SITE.SITE
WHERE
(((BI.PTNAME) Is Not Null)
AND ((PHM_POE_HIST.FUNCTION)="NW")
AND ((PHM_ORDERS.VALIDATED_DATE)=datereltoday(-1))
AND ((PHM_ORDERS.PRIORITY)="STAT"));