Reputation: 2859
How do I return all records from today until a given number of days in the future?
Select every record from table
where plandate = today and the next 14 days
select *
from joblist
WHERE plandate >= GETDATE() +14
Upvotes: 1
Views: 42
Reputation: 256
You can do something like this: (I'm omitting declares)
set @today = GETDATE()
set @endDate = DATEADD(DAY,15,GETDATE())
SELECT your_Records from TABLE
WHERE plandate >= @today
AND plandate < @endDate
You can also use the BETWEEN clause:
SELECT your_Records from TABLE
WHERE plandate BETWEEN @today AND @endDate
Upvotes: 2
Reputation: 460278
You can use DATEADD
:
WHERE plandate >= CAST(GETDATE() AS DATE)
AND plandate < DATEADD(day,+15, CAST(GETDATE() AS DATE))
Note that you have the Date
type only if you use at least SQL-Server 2008.
Upvotes: 1