How do I create future dates in SQL? For example, I want to be able to use my date range and show everything for just next month (purchase orders), then another for two months out, etc. I have used the fn NOW() for the current date/time but this doesn't help me at all for showing records for next month, etc.
This is for a SQL query that in doing in SQL Server 2008 R2.
If you use MySQL you can use:
SELECT date_col FROM your_table WHERE date_col BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 1 MONTH)
For MS-SQL (it should work):
SELECT date_col FROM your_table WHERE date_col BETWEEN GETDATE() AND DATEADD(Month, 1, GETDATE())
For Oracle (it should work):
SELECT date_col FROM your_table WHERE date_col BETWEEN SYSDATE AND add_months(SYSDATE, 1)