Get the first and last date of next month in MySQL

后端 未结 11 1141
感情败类
感情败类 2020-12-01 03:43

How can I get the first and last day of next month to be used in the where clause?

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 04:29

    First day of next month is simply last day of this month + 1:

    select affffdate(last_day(curdate()), 1)
    

    Last day of next month is simply last day of (today + 1 month):

    select last_day(curdate() + interval 1 month))
    

    These are the most straightforward solutions. You'll not be able to find a shorter one.


    If you need the first day of the current month, see https://stackoverflow.com/a/28966866/632951

提交回复
热议问题