Reputation: 2295
How can I add one month to a date that I am checking under the where clause?
select *
from Reference
where reference_dt + 1 month
Upvotes: 42
Views: 148449
Reputation: 31651
SELECT *
FROM Reference
WHERE reference_dt = DATEADD(MM, 1, reference_dt)
Upvotes: 2
Reputation: 63970
SELECT *
FROM Reference
WHERE reference_dt = DATEADD(MONTH, 1, another_date_reference)
Upvotes: 81
Reputation: 2688
DateAdd(m, 1, reference_dt)
This will add a month to the column value.
Upvotes: 2
Reputation: 33183
You can use DATEADD
function with the following syntax
DATEADD (datepart, number, date)
In your case, the code would look like this:
...
WHERE reference_dt = DATEADD(MM, 1, reference_dt)
Upvotes: 17
Reputation: 5294
DATEADD
is the way to go with this
See the W3Schools tutorial: http://www.w3schools.com/sql/func_dateadd.asp
Upvotes: 1