MySql query to select records with a particular date

后端 未结 4 1691
情歌与酒
情歌与酒 2021-02-02 07:41

so right now I\'m storing a the date of each search done on my site like this

2011-06-07 21:44:01

now I\'d like to execute a query to select al

4条回答
  •  你的背包
    2021-02-02 08:23

    I know the answer am about to post is long overdue but it can help someone who may experience the same problem.

    For my case I used:

    SELECT * 
    FROM tablename 
    WHERE dateCol >= date("2017-11-01") 
    AND dateCol < date("2017-11-01") + INTERVAL 1 DAY;
    

    Its faster than using DATE() function.

    If you are using a stored procedure, you could pass in the date as a string and supply it as an argument in place of ("2017-11-01")

提交回复
热议问题