I am trying to find all results with an end date within 30 days of now. The query I am trying for is:
SELECT * FROM title WHERE sales_end-date < now() + 30 days
How would I do this properly?
In Microsoft SQL Server, SELECT DATE is used to get the data from the table related to the date, the default format of date is ‘YYYY-MM-DD’. WHERE condition1, condition2,..; Now we will execute queries on SELECT DATE on database student in detail step-by-step:
Note:The date and time is returned as "YYYY-MM-DD HH-MM-SS" (string) or as YYYYMMDDHHMMSS.uuuuuu (numeric). Syntax NOW() Technical Details Works in:
To view items with a date on or after Feb 2, 2012, use the >= operator instead of the > operator. Returns items with a date between Feb 2, 2012 and Feb 4, 2012. Note: You can also use the Between operator to filter for a range of values, including the end points.
If today's date is Feb 2, 2012, you’ll see items for Feb 3, 2012. DatePart ("ww", [SalesDate]) = DatePart ("ww", Date ()) and Year ( [SalesDate]) = Year (Date ()) Returns items with dates during the current week. A week in Access starts on Sunday and ends on Saturday.
Use INTERVAL
SELECT *
FROM title
WHERE sales_end-date < DATE_ADD(CURRENT_TIMESTAMP, INTERVAL 30 day)
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