SQL query where Mydate should be less than 2 years

2019-08-17 17:01发布

问题:

I have one date column MyDate and I want those records in which MyDate should be less than current date by 2 years.

回答1:

For DB2 you can use this

MYDATECOLUMN < CURRENT DATE - 2 YEAR


回答2:

if DB Server = MS SQL , then try :-

select *
from myTable
where MyDate < dateadd(year, -2, getdate())


标签: sql database db2