mysql取今天,明天,工作日,周末,本周,下周,下月數(shù)據(jù) if ($date != '') {switch($date){//date_add 加 date_sub 減case '今天': $where .= " AND FROM_UNIXTIME(starttimefrom,'%Y-%m-%d') = curdate() "; break;case '明天': $where .= " AND FROM_UNIXT
mysql取今天,明天,工作日,周末,本周,下周,下月數(shù)據(jù)if ($date != '') { switch($date){//date_add 加 date_sub 減 case '今天': $where .= " AND FROM_UNIXTIME(starttimefrom,'%Y-%m-%d') = curdate() "; break; case '明天': $where .= " AND FROM_UNIXTIME(starttimefrom,'%Y-%m-%d') = date_add(curdate(), interval 1 day)"; break; case '工作日': $where .= " AND dayofweek(FROM_UNIXTIME(starttimefrom)) not in (1,7) "; break; case '周末': $where .= " AND dayofweek(FROM_UNIXTIME(starttimefrom)) in (1,7) "; break; case '本周': $where .= " AND YEARWEEK(FROM_UNIXTIME(starttimefrom,'%Y-%m-%d')) = YEARWEEK(now())"; break; case '下周': $where .= " AND ( FROM_UNIXTIME(starttimefrom,'%Y-%m-%d')>=SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-1) AND FROM_UNIXTIME(starttimefrom,'%Y-%m-%d')<=SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-7) ) "; break; case '下月': $where .= " AND FROM_UNIXTIME(starttimefrom,'%Y-%m') = date_format(DATE_add(curdate(), INTERVAL 1 MONTH),'%Y-%m') "; break; default: } }
?
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com