How to get first day of every corresponding month in mysql?

后端 未结 13 1844
野的像风
野的像风 2020-11-27 18:03

I want to get first day of every corresponding month of current year. For example, if user selects \'2010-06-15\', query demands to run from \'2010-06-01\' instead of \'2010

13条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 18:44

    This is old but this might be helpful for new human web crawlers XD

    For the first day of the current month you can use:

    SELECT LAST_DAY(NOW() - INTERVAL 1 MONTH) + INTERVAL 1 DAY;
    

提交回复
热议问题