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

后端 未结 13 1851
野的像风
野的像风 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:43

    You can use EXTRACT to get the date parts you want:

    EXTRACT( YEAR_MONTH FROM DATE('2011-09-28') )
    -- 201109
    

    This works well for grouping.

提交回复
热议问题