MySQL timestamp select date range

后端 未结 7 1070
栀梦
栀梦 2021-02-01 14:32

Not sure really where to start with this one. Can anyone help/point me in the right direction.

I have a timestamp column in MySQL and I want to select a date range for e

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-01 14:51

    Usually it would be this:

    SELECT * 
      FROM yourtable
     WHERE yourtimetimefield>='2010-10-01'
       AND yourtimetimefield< '2010-11-01'
    

    But because you have a unix timestamps, you'll need something like this:

    SELECT * 
      FROM yourtable
     WHERE yourtimetimefield>=unix_timestamp('2010-10-01')
       AND yourtimetimefield< unix_timestamp('2010-11-01')
    

提交回复
热议问题