如果你要严格要求是某一年的,那可以这样 查询一天: select * from table where to_days(column_time) = to_days(now()); select * from table where date(column_time) = curdate(); 查询一周: DAY) <= date(column_time); 查询一个月: select * from table where DATE_SUB(CURDATE(), INTERVAL 1 MONTH…
select * from wap_content where week(created_at) = week(now) 如果你要严格要求是某一年的,那可以这样 查询一天: select * from table where to_days(column_time) = to_days(now());select * from table where date(column_time) = curdate(); 查询一周: select * from table where DATE_SUB(C…
本周内:select * from wap_content where week(created_at) = week(now) 查询一天:select * from table where to_days(column_time) = to_days(now());select * from table where date(column_time) = curdate(); 查询7天:select * from table  where DATE_SUB(CURDATE(), INTERVA…
本周内:select * from wap_content where week(created_at) = week(now) 查询一天:select * from table where to_days(column_time) = to_days(now());select * from table where date(column_time) = curdate(); 查询7天:select * from table  where DATE_SUB(CURDATE(), INTERVA…
SELECT ID,SERVICE FROM new_schedules_spider_full WHERE SERVICE = 'WSA2' and date_sub(curdate(), interval 7 day) <= date(CREATE_TIME);…
常用计算日期的函数 日 date(日期) = CURDATE() 自然周 YEARWEEK(date_format(日期,'%Y-%m-%d') , 1) = YEARWEEK(now() , 1) 月 DATE_FORMAT( 日期, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' ) 计算周的原理 MySql计算周的函数有两个,一个是YEARWEEK(date, mode)一个是WEEK(date, mode) 他们的原理都是通过计算当前日期是属于一年…
1.查询当天的数据 select * from 表名 where TO_DAYS(时间字段)=TO_DAYS(NOW()); 2.查询当周的数据 select * from 表名 where YEARWEEK(DATE_FORMAT(时间字段,'%Y-%m-%d'))=YEARWEEK(NOW()); 3.查询当月的数据 select * from 表名 where DATE_FORMAT(时间字段,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m'); 4.查询昨天的数据…
SELECT birthday, )) + '-' + )) + '-' + )) AS datetime) AS Nbirthday FROM CRM_Customer WHERE birthday is not NULL AND (//当前时间要大于等于生日 Datediff(day, )) + '-' + )) + '-' + )) AND //当前时间要减去生日,要小于7天 Datediff(day, )) + '-' + )) + '-' + )) )…
$where .= " and (DAYOFWEEK( from_unixtime(`px_time`, '%Y-%m-%d')) = 1)";  //周日从1开始…
select subdate(curdate(),date_format(curdate(),'%w')-1) select subdate(curdate(),date_format(curdate(),'%w')-7)…