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 this be done?
SELECT *
FROM MyTable
WHERE CreatedDate >= getdate()
AND CreatedDate <= dateadd(day, 90, getdate())
Assuming you have a field for DateTime
, you could have your query look like this:
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)
For example:
Select * from Receipts where Sales_date > '08/28/2014 11:59:59PM'
In sql server, you can do
SELECT *
FROM table t
WHERE t.date > DATEADD(dd,90,now())
For SQL Server
select *
from YourTable
where DateCol between getdate() and dateadd(d, 90, getdate())
If you're using SQL Server it would be something like this:
DATEDIFF(d,GETDATE(),FUTUREDATE) BETWEEN 0 AND 90
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.