I am using SSMS 2017.
Below is a source table,
from the above table I want to filter only 'i' records
in which the date difference is >=6 months by satisfying the following condition (date2 <= dateadd(MONTH, +6, date1 - datepart(MONTH, date1) -1)) and the result should be as following,
any help from any one will be greatly appreciated.
Is this what you want?
select t.*
from t
where name <> 'i' or
date2 <= dateadd(month, +6, date1 - datepart(month, date1) -1))
I'm not quite sure what your condition is supposed to be doing, but this is what is in your question.
Based on the logic in the text:
select t.*
from t
where name <> 'i' or
date2 <= dateadd(month, +6, date1)