SELECT * FROM t_communication_log where record_number>'0'  and 
event_time> UNIX_TIMESTAMP('2003-07-28 00:00:00') and 
event_time< UNIX_TIMESTAMP('2003-07-29 00:00:00') ;

解决方案 »

  1.   

    SELECT * FROM t_communication_log where record_number>'0'  and 
    event_time> UNIX_TIMESTAMP('2003-07-28 00:00:00') and 
    event_time< UNIX_TIMESTAMP('2003-07-28 23:59:59') ;
      

  2.   

    ??不明白你的意思呀,你为什么不用这个呢SELECT * FROM t_communication_log 
      WHERE record_number>'0'  
        AND  
            TO_DAYS(event_time) >= TO_DAYS('2003-07-28')
        AND
            TO_DAYS(event_time) < TO_DAYS('2003-07-29')
      

  3.   

    如果event_time是表中的字段,类型为datetime的话看看是否可以直接比较,你试试。
    如果不行就加上FROM_UNIXTIME(even_time)
      

  4.   

    楼主用两个sql语句的结果:成功与不成功能不能说详细点,最好列举几个记录!从两个语句来看,后者最多比前者多包含了event_time为2003-07-28 23:59:59的记录!不过两者都没有完全包含28号所有的记录!假设event_time为datetime类型,如果表里的记录不是很多,或者event_time原来就不是索引字段,可以试试使用unix_timestamp把时间改为整数(秒数)来比较!
    SELECT * FROM t_communication_log where record_number>'0'  and 
    UNIX_TIMESTAMP(event_time) >= UNIX_TIMESTAMP('2003-07-28 00:00:00') and 
    UNIX_TIMESTAMP(event_time) <= UNIX_TIMESTAMP('2003-07-28 23:59:59') ;
      

  5.   

    如果event_time是表中的字段,类型为datetime的话可以直接比较的:
    SELECT * FROM t_communication_log where record_number>'0'  and 
    event_time> '2003-07-28 00:00:00' and 
    event_time< '2003-07-28 23:59:59' ;
      

  6.   

    昏, 我的意思是如标题!date_format('2003-07-28 23:59:59','%Y-%m-%d %h:%i:%s')不表示28号23点59分, 为什么?
    它就是表示28号0点0分0秒;我改试了,把那个字段改成datatime类型, 然后:
    SELECT * FROM t_communication_log where record_number>'0'  and 
    event_time> '2003-07-28 00:00:00'and 
    event_time< '2003-07-28 23:59:59' ;
    就成功了,哈哈,结贴!