mysql获取近7天日期

SELECT
      date_sub( curdate( ), INTERVAL 7 DAY ) AS a UNION
      SELECT
      date_sub( curdate( ), INTERVAL 6 DAY ) AS a UNION
      SELECT
      date_sub( curdate( ), INTERVAL 5 DAY ) AS a UNION
      SELECT
      date_sub( curdate( ), INTERVAL 4 DAY ) AS a UNION
      SELECT
      date_sub( curdate( ), INTERVAL 3 DAY ) AS a UNION
      SELECT
      date_sub( curdate( ), INTERVAL 2 DAY ) AS a UNION
      SELECT
      date_sub( curdate( ), INTERVAL 1 DAY ) AS a
      FROM DUAL
mysql获取近7天日期_第1张图片

 往前推几天或者几年

你可能感兴趣的:(mysql,数据库)