使用DateDiff查找持续时间(分钟)

Dou*_*cil 22 sql t-sql sql-server datediff

我试图Datediff找出columnA和之间的持续时间columnB.

SELECT datediff (minute, stime, etime)
from Exceptions2
where stime = [exceptions2].starttime
and etime = [exceptions2].endtime
Run Code Online (Sandbox Code Playgroud)

这会产生错误.任何人都可以帮我解决我做错的事吗?

Ray*_*und 38

如何尝试这个,不知道为什么你有stime = [exceptions2] .starttime和etime = [exceptions2] .endtime

SELECT datediff(minute, starttime, endtime) from Exceptions2
Run Code Online (Sandbox Code Playgroud)