Retrieving data from MYSQL based on week number

后端 未结 3 906
迷失自我
迷失自我 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:29

    Use WEEK

    select * from your_table
    where week(`Date`) = week('2012-12-01')
    

    If you want to get only records from the current week you can do

    select * from your_table
    where week(`Date`) = week(curdate())
    

提交回复
热议问题