mysql5日期类型datetime查询范围值

1.DATE_FORMAT函数

SELECT a.create_time FROM account_log a 

WHERE  a.create_time >=  DATE_FORMAT('2014-05-10 00:00:00','%Y-%m-%d %H:%i:%s')

             AND a.create_time <= DATE_FORMAT('2014-05-25 23:59:59','%Y-%m-%d %H:%i:%s')    

2.STR_TO_DATE函数

SELECT a.create_time FROM account_log a 

WHERE  a.create_time >=  STR_TO_DATE('2014-05-10 00:00:00','%Y-%m-%d %H:%i:%s')

             AND a.create_time <= STR_TO_DATE('2014-05-25 23:59:59','%Y-%m-%d %H:%i:%s')

3.直接比较

SELECT a.create_time,a.order_no FROM account_log a 

WHERE  a.create_time >=  '2014-05-10 00:00:00'

             AND a.create_time <= '2014-05-25 23:59:59'

你可能感兴趣的:(DateTime)