MySQL date comparison

后端 未结 7 531
有刺的猬
有刺的猬 2020-12-18 06:30

Dates are stored in DB as such: \"2011-05-26 11:00:00\" in a datetime field. I\'d like to find all rows where the date is greater than the first of this month, ie: 2011-05-0

7条回答
  •  無奈伤痛
    2020-12-18 06:59

    DATETIME fields can filtered just like integer fields, example:

    SELECT * FROM `table` WHERE `date` > '2011-05-01 09:00:00'
    

    In case you really want to convert to Unix timestamps, have a look at the UNIX_TIMESTAMP function.

提交回复
热议问题