mysql query the number of days in the previous month / the first day of the current month / the first day of the previous month

select (DATEDIFF(DATE_ADD(curdate(), INTERVAL - DAY(curdate())+ 1 DAY), date_add(curdate()- DAY(curdate())+ 1, INTERVAL -1 MONTH))) 上月总天数
     , DATE_ADD(curdate(),interval -day(curdate())+1 day) The first day of the month
     , date_add(curdate()-day(curdate())+1,interval -1 month ) The first day of the previous month

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326643772&siteId=291194637