今天: Select * From log Where to_days(cdate) = to_days(now()); 昨天: Select * From log Where to_days( NOW( ) ) - to_days(cdate) <= 1 近7天: Select * From log Where date_sub(CURDATE(), Interval 7 DAY) <= date(cdate) 近30天: Select * From log Where date_sub(CURDATE(), Interval 30 DAY) <= date(cdate) 本月: Select * From log Where date_format(cdate, ‘%Y%m‘ ) = date_format( CURDATE( ) , ‘%Y%m‘ ) 本周: Select * From log Where month(cdate) = month(curdate()) and week(cdate) = week(curdate()) 上月: Select * From log Where period_diff( date_format( now( ),‘%Y%m‘ ) , date_format(cdate,‘%Y%m‘ ) ) =1 今年: Select * From log Where year( from_unixtime( cdate ) ) = year( curdate() ) 本季度: Select * From log Where quarter( from_unixtime( cdate ) ) = quarter( curdate( ))
时间: 2024-12-28 06:03:43