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?
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.
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.
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.
SELECT * FROM MyTable WHERE CreatedDate >= getdate() AND CreatedDate <= dateadd(day, 90, getdate())
http://msdn.microsoft.com/en-us/library/ms186819.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With