我尝试了几种方法,但这是我的SQL伪代码:
select count(*) as counter
where startDate and endDate is 30 minutes and archived = 1.
mssql字段的数据类型为datetime
我的另一个想法是将其提交到select
语句并向dateadd
添加datdiff
,但我不确定如何解释这两个单独的字段( startDate
,EndDate
)...
我希望有人可以理顺我。
答案 0 :(得分:4)
SELECT COUNT(*)
FROM mytable
WHERE endDate <= DATEADD(minute, 30, startDate)
AND archieved = 1
答案 1 :(得分:2)
SELECT COUNT(*)
FROM YourTable
WHERE DATEDIFF(MINUTE,StartDate,EndDate) <= 30
AND Archived = 1