Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

showing that a date is greater than current date

Tags:

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?

like image 639
GabrielVa Avatar asked Jul 13 '11 12:07

GabrielVa


People also ask

How do I get data greater than the current date in SQL?

In this article, we will see the SQL query to check if DATE is greater than today's date by comparing date with today's date using the GETDATE() function. This function in SQL Server is used to return the present date and time of the database system in a 'YYYY-MM-DD hh:mm: ss. mmm' pattern.

Can you compare dates in SQL?

Here we will see, SQL Query to compare two dates. This can be easily done using equals to(=), less than(<), and greater than(>) operators. In SQL, the date value has DATE datatype which accepts date in 'yyyy-mm-dd' format. To compare two dates, we will declare two dates and compare them using the IF-ELSE statement.

Can we compare date with timestamp?

A date, time, or timestamp value can be compared with another value of the same data type, a datetime constant of the same data type, or with a string representation of a value of that data type. Additionally, a TIMESTAMP WITHOUT TIME ZONE value can be compared with a TIMESTAMP WITH TIME ZONE value.


1 Answers

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

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

like image 129
Massimiliano Peluso Avatar answered Oct 03 '22 07:10

Massimiliano Peluso