[英]showing that a date is greater than current date
How would I show something in SQL where the date is greater than the current date?如何在 SQL 中显示日期大于当前日期的内容?
I want to pull out data that shows everything greater from today (now) for the next coming 90 days.我想提取数据,显示从今天(现在)开始的未来 90 天的一切。
I was thinking =< {fn NOW()}
but that doesnt seem to work in my sql view here.我在想=< {fn NOW()}
但这似乎在我的 sql 视图中不起作用。
How can this be done?如何才能做到这一点?
SELECT *
FROM MyTable
WHERE CreatedDate >= getdate()
AND CreatedDate <= dateadd(day, 90, getdate())
http://msdn.microsoft.com/en-us/library/ms186819.aspx http://msdn.microsoft.com/en-us/library/ms186819.aspx
Assuming you have a field for DateTime
, you could have your query look like this:假设您有一个DateTime
字段,您的查询可能如下所示:
SELECT *
FROM TABLE
WHERE DateTime > (GetDate() + 90)
For those that want a nice conditional:对于那些想要一个好的条件的人:
DECLARE @MyDate DATETIME = 'some date in future' --example DateAdd(day,5,GetDate())
IF @MyDate < DATEADD(DAY,1,GETDATE())
BEGIN
PRINT 'Date NOT greater than today...'
END
ELSE
BEGIN
PRINT 'Date greater than today...'
END
Select * from table where date > 'Today's date(mm/dd/yyyy)'
You can also add time in the single quotes(00:00:00AM)您还可以在单引号中添加时间(00:00:00AM)
For example:例如:
Select * from Receipts where Sales_date > '08/28/2014 11:59:59PM'
In sql server, you can do在 sql 服务器中,你可以做
SELECT *
FROM table t
WHERE t.date > DATEADD(dd,90,now())
For SQL Server适用于 SQL 服务器
select *
from YourTable
where DateCol between getdate() and dateadd(d, 90, getdate())
If you're using SQL Server it would be something like this:如果您使用的是 SQL 服务器,它将是这样的:
DATEDIFF(d,GETDATE(),FUTUREDATE) BETWEEN 0 AND 90
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.