0
我正在嘗試計算SAS EG中兩個時間列之間的差異。我正在編寫一個SQL查詢來做到這一點。但我得到不正確的答案。這裏是我的查詢:SQL中時間列之間的差異
select
Time_DP, Time_AR, (Time_DP-time_AR) as timediff from table1
-------
這是我得到
Time_DP Time_AR timediff
23:00:00 20:31:00 22900
00:53:00 23:59:00 -230600
這些都只是兩行,我得到的例子。我猜測他的timdiff值是以秒爲單位的。如果是這樣,他們應該是第一排149*60
秒,即8940
。
我還需要在hh:mm format
即02:29
我已經試過這科拉姆使用下述功能,沒有一次成功:
--DATEDIFF(hour, Time_DP,time_AR) AS timediff
(Error: Hour is not a column of an inserted table. SQL code = -206, SQL state=42703)
--TIMEDIFF(CAST(AS TIME), CAST(time_AR AS TIME)) AS TIMIFF
(Error: No function by the name timediff having compatible arguments was found in the current path. sql code=-440, sql state=42284)
--DATEADD(SECOND, - DATEDIFF(SECOND, time_AR, Time_DP),) as timediff,
(ERROR: Second is not a column of an inserted table, updated table or any table identified in a from clause.SQL code = -206, SQL state=42703)
--Convert(time(0),(Convert(datetime,Time_DP) - Convert(datetime,Time_AR)),8) as timediff
(ERROR: Datetime is not a column of an inserted table, updated table or any table identified in a from clause.SQL code = -206, SQL state=42703)
--DATEDIFF(HOUR,Time_AR,Time_DP) AS timediff
(ERROR: Hour is not a column of an inserted table, updated table or any table identified in a from clause.SQL code = -206, SQL state=42703)
感謝
錯誤的** mysql **標籤應該從這個問題中刪除。它應該被替換爲一個指向正在使用的_actual_ RDBMS的標記(Oracle,Postgres,SQL Server等) – spencer7593
是@ spencer7593是正確的,它不是mysql和錯誤消息不是mysql錯誤消息。 –