SQL query where Mydate should be less than 2 years from the current date

回眸只為那壹抹淺笑 提交于 2019-12-11 16:48:27

问题


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())


来源:https://stackoverflow.com/questions/19582599/sql-query-where-mydate-should-be-less-than-2-years-from-the-current-date

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!