0
我有一個顯示訂單週轉時間的MS Access查詢。兩個問題:將僞24小時時鐘時間轉換爲12小時時鐘時間
- 的時間是24小時制時間時間(例如:0105),所以當你減去醫囑時間的驗證時間,你會得到一個值,既不是在幾分鐘或幾小時,這樣你就可以不會簡單地將其轉換爲分鐘(即: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"));
我同意 - 首先將數據解析爲適當的24小時制時間,然後使用datediff。 – 2013-02-27 01:02:32