--
今天
select DATE_FORMAT(NOW(), ' %Y-%m-%d 00:00:00 ' ) AS ' 今天开始 ' ;
select DATE_FORMAT(NOW(), ' %Y-%m-%d 23:59:59 ' ) AS ' 今天结束 ' ;
-- 昨天
select DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 1 DAY ), ' %Y-%m-%d 00:00:00 ' ) AS ' 昨天开始 ' ;
select DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 1 DAY ), ' %Y-%m-%d 23:59:59 ' ) AS ' 昨天结束 ' ;
-- 上周
select DATE_FORMAT( DATE_SUB( DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY ), INTERVAL 1 WEEK), ' %Y-%m-%d 00:00:00 ' ) AS ' 上周一 ' ;
select DATE_FORMAT( SUBDATE(CURDATE(), WEEKDAY(CURDATE()) + 1 ), ' %Y-%m-%d 23:59:59 ' ) AS ' 上周末 ' ;
-- 本周
-- select DATE_FORMAT( DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) DAY), '%Y-%m-%d 00:00:00') AS '本周一';
-- select DATE_FORMAT( DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) DAY), '%Y-%m-%d 23:59:59') AS '本周末';
-- 本周
select DATE_FORMAT( SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(), ' %w ' ) - 1 ), ' %Y-%m-%d 00:00:00 ' ) AS ' 本周一 ' ;
select DATE_FORMAT( SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(), ' %w ' ) - 7 ), ' %Y-%m-%d 23:59:59 ' ) AS ' 本周末 ' ;
-- 上月
select DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 1 MONTH ), ' %Y-%m-01 00:00:00 ' ) AS ' 上月初 ' ;
select DATE_FORMAT( LAST_DAY(DATE_SUB(CURDATE(), INTERVAL 1 MONTH )), ' %Y-%m-%d 23:59:59 ' ) AS ' 上月末 ' ;
-- 本月
select DATE_FORMAT( CURDATE(), ' %Y-%m-01 00:00:00 ' ) AS ' 本月初 ' ;
select DATE_FORMAT( LAST_DAY(CURDATE()), ' %Y-%m-%d 23:59:59 ' ) AS ' 本月末 ' ;
select DATE_FORMAT(NOW(), ' %Y-%m-%d 00:00:00 ' ) AS ' 今天开始 ' ;
select DATE_FORMAT(NOW(), ' %Y-%m-%d 23:59:59 ' ) AS ' 今天结束 ' ;
-- 昨天
select DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 1 DAY ), ' %Y-%m-%d 00:00:00 ' ) AS ' 昨天开始 ' ;
select DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 1 DAY ), ' %Y-%m-%d 23:59:59 ' ) AS ' 昨天结束 ' ;
-- 上周
select DATE_FORMAT( DATE_SUB( DATE_SUB(CURDATE(), INTERVAL WEEKDAY(CURDATE()) DAY ), INTERVAL 1 WEEK), ' %Y-%m-%d 00:00:00 ' ) AS ' 上周一 ' ;
select DATE_FORMAT( SUBDATE(CURDATE(), WEEKDAY(CURDATE()) + 1 ), ' %Y-%m-%d 23:59:59 ' ) AS ' 上周末 ' ;
-- 本周
-- select DATE_FORMAT( DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) DAY), '%Y-%m-%d 00:00:00') AS '本周一';
-- select DATE_FORMAT( DATE_SUB(NOW(), INTERVAL WEEKDAY(NOW()) DAY), '%Y-%m-%d 23:59:59') AS '本周末';
-- 本周
select DATE_FORMAT( SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(), ' %w ' ) - 1 ), ' %Y-%m-%d 00:00:00 ' ) AS ' 本周一 ' ;
select DATE_FORMAT( SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(), ' %w ' ) - 7 ), ' %Y-%m-%d 23:59:59 ' ) AS ' 本周末 ' ;
-- 上月
select DATE_FORMAT( DATE_SUB(CURDATE(), INTERVAL 1 MONTH ), ' %Y-%m-01 00:00:00 ' ) AS ' 上月初 ' ;
select DATE_FORMAT( LAST_DAY(DATE_SUB(CURDATE(), INTERVAL 1 MONTH )), ' %Y-%m-%d 23:59:59 ' ) AS ' 上月末 ' ;
-- 本月
select DATE_FORMAT( CURDATE(), ' %Y-%m-01 00:00:00 ' ) AS ' 本月初 ' ;
select DATE_FORMAT( LAST_DAY(CURDATE()), ' %Y-%m-%d 23:59:59 ' ) AS ' 本月末 ' ;