开发者

Find the difference between two date fields that are within a certain time parameter

I have tried this a few ways but here is my pseudo-code for SQL:

select count(*) as counter 
where startDate and endDate is 30 minutes and archived = 1.  

The datatypes for mssql fields are datetime

The other idea I had was to bring it up to the select statement and add a dateadd to the datdiff but I was not s开发者_Go百科ure how to account for the two seperate fields (startDate,EndDate)...

I hope someone can straighten me out.


SELECT  COUNT(*)
FROM    mytable
WHERE   endDate <= DATEADD(minute, 30, startDate)
        AND archieved = 1


SELECT COUNT(*)
FROM YourTable
WHERE DATEDIFF(MINUTE,StartDate,EndDate) <= 30
AND Archived = 1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜