How do I query between two dates using MySQL?

前端 未结 10 2249
滥情空心
滥情空心 2020-11-22 00:58

The following query:

SELECT * FROM `objects` 
WHERE (date_field BETWEEN \'2010-09-29 10:15:55\' AND \'2010-01-30 14:15:55\')

returns nothin

10条回答
  •  终归单人心
    2020-11-22 01:46

    Is date_field of type datetime? Also you need to put the eariler date first.

    It should be:

    SELECT * FROM `objects` 
    WHERE  (date_field BETWEEN '2010-01-30 14:15:55' AND '2010-09-29 10:15:55')
    

提交回复
热议问题