GabrielVa
GabrielVa

Reputation: 2388

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 this be done?

Upvotes: 23

Views: 162039

Answers (7)

Massimiliano Peluso
Massimiliano Peluso

Reputation: 26737

SELECT * 
FROM MyTable 
WHERE CreatedDate >= getdate() 
AND CreatedDate <= dateadd(day, 90, getdate())

http://msdn.microsoft.com/en-us/library/ms186819.aspx

Upvotes: 38

Jamie M.
Jamie M.

Reputation: 722

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 

Upvotes: 2

Nick Brekalo
Nick Brekalo

Reputation: 41

Assuming you have a field for DateTime, you could have your query look like this:

SELECT *
FROM TABLE
WHERE DateTime > (GetDate() + 90)

Upvotes: 4

JMoen
JMoen

Reputation: 11

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'

Upvotes: 1

Mikael Eriksson
Mikael Eriksson

Reputation: 138960

For SQL Server

select *
from YourTable
where DateCol between getdate() and dateadd(d, 90, getdate())

Upvotes: 1

David
David

Reputation: 1611

If you're using SQL Server it would be something like this:

DATEDIFF(d,GETDATE(),FUTUREDATE) BETWEEN 0 AND 90

Upvotes: 0

ysrb
ysrb

Reputation: 6740

In sql server, you can do

SELECT *
FROM table t
WHERE t.date > DATEADD(dd,90,now())

Upvotes: 3

Related Questions