mysql今天向前推90天_sqlserver里面取当前时间向前推三个月数据

展开全部

这个看你用的什么62616964757a686964616fe78988e69d8331333365646238数据库,还有你的自动是什么数据类型:

比如oracle,日期类型:

select * from tablea where datecol between add_months(trunc(sysdate(),-3) and trunc(sysdate()

如果是sqlserver

select * from tablea where datecol between dateadd(mm,-3,getdate()) and getdate();

/p>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Test

function get3MonthBefor(){

var resultDate,year,month,date,hms;

var currDate = new Date();

year = currDate.getFullYear();

month = currDate.getMonth()+1;

date = currDate.getDate();

hms = currDate.getHours() + ':' + currDate.getMinutes() + ':' + (currDate.getSeconds() < 10 ? '0'+currDate.getSeconds() : currDate.getSeconds());

switch(month)

{

case 1:

case 2:

case 3:

month += 9;

year--;

break;

default:

month -= 3;

break;

}

month = (month < 10) ? ('0' + month) : month;

resultDate = year + '-'+month+'-'+date+' ' + hms;

return resultDate;

}

document.write(get3MonthBefor());

运行效果图如下:

8ecb9ee6995337e2776f7f4ce361a678.png


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部