我的MYSQL里的一个字段时间项(logTime)当然设置的为字符型,如2005-10-22 12:31:58.777,现在要以时间为条件查询,如何写我用select * from 表 where logTime=2005-10-22
查询出来结果为空,为什么能不能改logTime为mid(logTime,1,10),结果也为空

解决方案 »

  1.   

    上面的用mid(logTime,1,10)="2005-10-22"可以了,但如果想查2005-9-22到2005-10-22的数据,怎么办呢,急!!1
      

  2.   

    str = "2005-10-22 12:31:58,777"
     str = Left(str, 10)
     FormatDateTime(str, vbShortDate)
    select * from 表 where FormatDateTime(logTime, vbShortDate)< dateserial(2005-10-22) And  FormatDateTime(logTime, vbShortDate)> dateserial(2005-09-22)
      

  3.   

    select * from bussinessrecords where left(logTime,10)="2005-10-20";
    select * from bussinessrecords where mid(logTime,1,10)="2005-10-20";是可以的
    但select * from bussinessrecords where formatdatetime(left(logTime,10),vbshortdate)="2005-10-20";
    就不对了,提示语句不正确,换成了
    select * from bussinessrecords where formatdatetime(left(logTime,10),vbshortdate)=2005-10-20;也不行,加##更不行
      

  4.   

    select * from bussinessrecords where left(logTime,10)>="2005-06-20" and LEFT(logTime,10)<="2005-10-22";呵呵,这样居然可以
      

  5.   

    select * from bussinessrecords where left(logTime,10) between "2005-06-20" and  "2005-10-22";
      

  6.   

    select * from bussinessrecords where Format(logTime,"YYYY-MM-DD") between "2005-06-20" and  "2005-10-22";