How can I add one month to a date that I am checking under the where clause?
e.g.:
select *
from Reference
where reference_dt + 1 month
This question is related to
sql
sql-server
tsql
datetime
DATEADD
is the way to go with this
See the W3Schools tutorial: http://www.w3schools.com/sql/func_dateadd.asp
Use DATEADD
:
DATEADD(month, 1, reference_dt)
select * from Reference where reference_dt = DATEADD(mm, 1, reference_dt)
Look at DATEADD
SELECT DATEADD(mm, 1, OrderDate)AS TimeFrame
Here's the MSDN
In your case
...WHERE reference_dt = DATEADD(MM,1, myColDate)
DateAdd(m,1,reference_dt)
will add a month to the column value
Source: Stackoverflow.com