– 获取明天的日期
SELECT DATE_FORMAT(DATE_ADD(NOW(),INTERVAL 1 DAY),’%Y-%m-%d’);
– 获取今天的日期
select date_format(now(), ‘%Y-%m-%d 00:00:00’) sell_month_date
– 获取昨天的日期
SELECT DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 DAY),’%Y-%m-%d 59:59:59’);
– 获取最后一天
select concat(last_day(curdate()),’ 59:59:59’) sell_month_date
– 上个月第一天
select date_sub(date_sub(date_format(now(),’%y-%m-%d 00:00:00’),interval extract(
day from now())-1 day),interval 1 month)
– 上个月最后一天
select date_sub(date_sub(date_format(now(),’%y-%m-%d’),interval extract(
day from now()) day),interval 0 month) as date
– 这个月第一天
select date_sub(date_sub(date_format(now(),’%y-%m-%d’),interval extract(
day from now())-1 day),interval 0 month)
– 这个月最后一天
select last_day(curdate());
– 当月总天数
select day(LAST_DAY(now()))
– 今年第一天
SELECT DATE_FORMAT(DATE_SUB(CURDATE(),INTERVAL dayofyear(now())-1 DAY),’%Y-%m-%d’) AS c_year
– 去年第一天
SELECT DATE_FORMAT((DATE_SUB((DATE_SUB(NOW(),INTERVAL dayofyear(now())-1 DAY)),INTERVAL 1 YEAR)),’%Y-%m-%d’) AS last_year
#当年最后一天:
SELECT concat(YEAR(now()),’-12-31’);
#去年最后一天
SELECT concat(YEAR(now())-1,’-12-31’);