In MySQL, how to return the week of the month?

前端 未结 6 1872
独厮守ぢ
独厮守ぢ 2020-12-10 15:17

The year is divided into 12 months. We can break down a month in four weeks.

In MySQL, how to return the week of the month? (Example: first week: 2 entries, second w

6条回答
  •  有刺的猬
    2020-12-10 15:33

    SELECT WEEK(my_date_field,5) - WEEK(DATE_SUB(my_date_field, 
    INTERVAL DAYOFMONTH(my_date_field) - 1 DAY),5) + 1
    

    Or you can see here.

提交回复
热议问题