Mysql Compare two datetime fields

后端 未结 4 703
花落未央
花落未央 2020-12-02 10:08

I want to compare two dates with time, I want all the results from tbl where date1 > date2

Select * From temp where mydate > \'2009-06-29          


        
4条回答
  •  伪装坚强ぢ
    2020-12-02 10:23

    You can use the following SQL to compare both date and time -

    Select * From temp where mydate > STR_TO_DATE('2009-06-29 04:00:44', '%Y-%m-%d %H:%i:%s');
    

    Attached mysql output when I used same SQL on same kind of table and field that you mentioned in the problem-

    enter image description here

    It should work perfect.

提交回复
热议问题