取当前日期 到 前3个月的sql记录 怎么写

取当前日期 到 前3个月的sql记录 怎么写

select * from t where 日期字段名字>DATEADD ( mm, -3, getdate())

//t 是你的表名

 

 


现在程序里得到当前时间和3个月前的时间
Date nowDate=new Date();
Date oldDate=new Date();
oldDate.setMonth(oldDate.getMonth()-3);

select * from tab where 日期字段>oldDate and 日期字段<newDate

你可能感兴趣的:(取当前日期 到 前3个月的sql记录 怎么写)