MySQL - select data from database between two dates

后端 未结 8 1209
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 22:07

I have saved the dates of a user\'s registration as a datetime, so that\'s for instance 2011-12-06 10:45:36. I have run this query and I expected this item

8条回答
  •  囚心锁ツ
    2020-11-27 22:50

    You can use MySQL DATE function like below

    For instance, if you want results between 2017-09-05 till 2017-09-09

    SELECT DATE(timestamp_field) as date FROM stocks_annc WHERE DATE(timestamp_field) >= '2017-09-05' AND DATE(timestamp_field) <= '2017-09-09'
    

    Make sure to wrap the dates within single quotation ''

    Hope this helps.

提交回复
热议问题