SQL – 取得超過十分鐘欄位未更新

select DateDiff(n,欄位,GetDate()) AS DELAYTIME,* from 表格 where DateDiff(n,欄位,GetDate())>10 ORDER BY DELAYTIME

語法:

DATEDIFF ( datepart , startdate , enddate )
datepart 縮寫
year yy, yyyy
quarter qq, q
month mm, m
dayofyear dy, y
day dd, d
week wk, ww
hour hh
minute mi, n
second ss, s
millisecond ms
microsecond mcs
nanosecond ns

startdate

 

參考:
https://msdn.microsoft.com/zh-tw/library/ms189794.aspx