根据指定日期取不超过指定日期的周一至周日
select
date_add('2011-04-10', interval - ( 12 + dayofweek('2011-04-10')) day) '不超过指定日期所在上周周一',
date_add('2011-04-10', interval - ( 6 + dayofweek('2011-04-10')) day) '不超过指定日期所在上周日',
date_add('2011-04-10', interval - ( 5 + dayofweek('2011-04-10')) day) '不超过指定日期所在周一',
date_add('2011-04-10', interval - ( -1 + dayofweek('2011-04-10')) day) '不超过指定日期所在周日'
select date_add( '2012-04-09',interval - (dayofweek('2012-04-09' ) + 5 ) % 7 day ) '本周一';
根据指定日期取上一月第一天和最后一天
select
date_sub(date_sub('2011-04-10',interval extract(day from '2011-04-10')-1 day),interval 1 month) '上月第一天',
date_sub(date_sub('2011-04-10',interval extract(day from '2011-03-10') day),interval 0 month) '上月最后一天'