Retrieving data from MYSQL based on week number

后端 未结 3 908
迷失自我
迷失自我 2021-01-27 12:59

I am having a table as follows in MYSQL:

proj_id|hoursWorked|Date.  

The date field is of type Date; I want to retrieve all the e

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-27 13:22

    use MySQL WEEK() function.

    SELECT WEEK(dateColumn)
    FROM...
    WHERE WEEK(dateColumn) = 1
    
    • WEEK()

    from MySQL Docs

    This function returns the week number for date. The two-argument form of WEEK() enables you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53.

提交回复
热议问题