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?
I want to pull out data that shows everything greater from today (now) for the next coming 90 days.
I was thinking =< {fn NOW()}
but that doesnt seem to work in my sql view here.
How can thi开发者_开发问答s be done?
SELECT *
FROM MyTable
WHERE CreatedDate >= getdate()
AND CreatedDate <= dateadd(day, 90, getdate())
http://msdn.microsoft.com/en-us/library/ms186819.aspx
Assuming you have a field for DateTime
, you could have your query look like this:
SELECT *
FROM TABLE
WHERE DateTime > (GetDate() + 90)
In sql server, you can do
SELECT *
FROM table t
WHERE t.date > DATEADD(dd,90,now())
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
For SQL Server
select *
from YourTable
where DateCol between getdate() and dateadd(d, 90, getdate())
Select * from table where date > 'Today's date(mm/dd/yyyy)'
You can also add time in the single quotes(00:00:00AM)
For example:
Select * from Receipts where Sales_date > '08/28/2014 11:59:59PM'
If you're using SQL Server it would be something like this:
DATEDIFF(d,GETDATE(),FUTUREDATE) BETWEEN 0 AND 90
精彩评论