MySQL: Select data from a table where the date falls in the current Week and current Month

前端 未结 3 913
孤城傲影
孤城傲影 2021-01-24 19:34

I am creating a web app where if a user clicks on Link called \"WEEK\", the page shows up all the posts which were submitted in that week. There\'s also an option to view all th

3条回答
  •  走了就别回头了
    2021-01-24 19:46

    There are several MySQL functions that do things like this for you

    SELECT * FROM posts
    WHERE
       WEEK(post_date) = WEEK(CURDATE())
       AND
       MONTH(post_date) = MONTH(CURDATE())
    

提交回复
热议问题