SELECT
[NAMENO],
[FIRSTNAME],
[MIDNAME],
[LASTNAME],
[SEX],
[STATUSOF],
[RELEASEDT],
CONVERT(VARCHAR(10), DOBDT, 101) AS DOBDT
FROM
database
WHERE
ReleaseDT >= dateadd(minute,datediff(minute,60,GETDATE()),0)
AND ReleaseDT < dateadd(minute,datediff(minute,0,GETDATE()),0)
I am wanting to get anyone that has a "releasedt" in the past 60 mins if that makes of sense? right now its pull the last 60 days..
如果有意义的话,我想在过去60分钟内找到任何有“发布”的人?现在它拉了最后60天..
Any suggestions??
1 个解决方案
#1
3
It's just:
where ReleaseDT >= dateadd(minute, -60, getdate())
and ReleaseDT <= getdate()
Nesting dateadd
and datediff
(like you did in your code in the question) is not necessary.
In fact, datediff
calculates the difference (in hours, minutes...whatever) between two datetime values, so you don't need it at all when you just want to get "now minus 60 minutes".
嵌套dateadd和datediff(就像你在问题中的代码中所做的那样)是没有必要的。事实上,datediff会计算两个日期时间值之间的差异(以小时,分钟......为单位),因此当您只想获得“现在减去60分钟”时,根本不需要它。
#1
3
It's just:
where ReleaseDT >= dateadd(minute, -60, getdate())
and ReleaseDT <= getdate()
Nesting dateadd
and datediff
(like you did in your code in the question) is not necessary.
In fact, datediff
calculates the difference (in hours, minutes...whatever) between two datetime values, so you don't need it at all when you just want to get "now minus 60 minutes".
嵌套dateadd和datediff(就像你在问题中的代码中所做的那样)是没有必要的。事实上,datediff会计算两个日期时间值之间的差异(以小时,分钟......为单位),因此当您只想获得“现在减去60分钟”时,根本不需要它。