以下为访问ACCESS数据库的语句,错误在
 +' and SurveyTime>'+convert((timetostr(Vmaxdatetime),text,datetime) ;这一行,
请教高手怎么解决?ADOQueryass2.SQL.Text:='select * from '+Vdatatable+' where '    
         +'SurveyPointNo='+''''+VASSnodecode +''''
         +' and SurveyTime>'+convert((timetostr(Vmaxdatetime),text,datetime) ; 
其中SurveyTime字段为时间类型,Vmaxdatetime变量为Tdatetime类型

解决方案 »

  1.   

    以前试着这样写:and SurveyTime>'+''''+timetostr(Vmaxdatetime)+'''' ;
    也不行,我想是字段类型不同的原因,所以用convert转换,请教此处应如何使用convert函数
      

  2.   

    and SurveyTime>#'+timetostr(Vmaxdatetime)+'#' ;
      

  3.   

    或者convert(SurveyTime,  ??),请教如何写呢?急盼!!!
      

  4.   

    如果你数据库内surveyTime存的日期格式 为yyyy-mm-dd的类型的话,就用下边这句,如果为其它类型格式的话,改一下formatdatetime语句就可以了。and SurveyTime>#'+formatdatetime('yyyy-mm-dd',Vmaxdatetime)+'#' ;
      

  5.   

    1,时间查询用两边用"#"
    2,'select * from '+Vdatatable+' where  SurveyPointNo='''+VASSnodecode+'''' 
    这样就可以拉
      

  6.   

    只有时间格式为例如,8:00,没有日期
    请教这样写吗?SurveyTime >#'+formatdatetime('h:mm',Vmaxtime)+'#' ;运行不能通过?
      

  7.   

    执行到该sql语句后提示:不正常地定义数据对象,提供了不一致或不完整的信息
    请教是为什么呀?
      

  8.   

    SurveyTime >'''+formatdatetime('hh:mm',Vmaxtime)+'''';
    你试试。
      

  9.   

    ADOQueryass2.SQL.Text:='select * from '+Vdatatable+' where '    
             +'SurveyPointNo='+''''+VASSnodecode +''''
             +' and SurveyTime>'+ (timetostr(Vmaxdatetime)) ; 
    顺便可以把SQL语句SHOW出来看看
      

  10.   

    时间有“:”,在Delphi的SQL中“:”后面的将看成参数,所以时间最好用参数传出去!
    ADOQuery1.sql.add('....SurveyTime >:a');
    ADOQuery1.Parameters[0].Value := Time;
      

  11.   

    按照SurveyTime >'''+formatdatetime('hh:mm',Vmaxtime)+'''';
    又提示:
    标准表达式中数据类型不匹配?
      

  12.   

    SurveyTime >#'+formatdatetime('hh:mm',Vmaxtime)+'#' 
    or
    SurveyTime >'+formatdatetime('hh:mm',Vmaxtime)你再试试,如果不行话,就不太清楚了。不过access中SurveyTime即然只存 hh:mm,你又何必设为时间类型的呢,可以设为字符型(个人认为) 。