Get the first and last date of next month in MySQL

后端 未结 11 1144
感情败类
感情败类 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:30

    # FIRST date of next month
    select date_sub(date_add(curdate(), interval 1 month), interval day(curdate())-1 day);
    
    # LAST date of next month
    select date_sub(date_add(curdate(), interval 2 month), interval day(curdate()) day);
    

    not sure that's the shortest queries, but they do work

提交回复
热议问题