如何在数据库中获取到和当前日期相比3年内的数据

2025-03-21 19:38:10
推荐回答(2个)
回答1:

就是你要三年内的资料咯,很简单用sql语句select * from 表 where datediff(yy,时间,getdate())<4就行了~

回答2:

select * from 表名 where datediff(year,时间字段,getdate())<=3