是否用的DateTime数据类型

解决方案 »

  1.   

    没有必要吧!
    我是对commandtext赋值,没有用到时间日期变量。
      

  2.   

    注意除了日期之外还有时间!
    建议仅把条件设定为日期比如
    select * from table1 where year(logdate)=2002 and 
                                month(logdate)=3 and day(logdate)=1
      

  3.   

    如果你使用Oracle
    TO_DATE()
    如果你使用Sybase
    '2002-3-1'
      

  4.   

    我特地做过实验:
    select * from table1 where logdate=2002-3-1
      作用无效,因为日期型数据必须加引号。(Sql Server格式里)
    select * from table1 where logdate='2002-3-1'
    那么就可以了。所以
    sql1:='select * from table1 where logdate=''2002-3-1''';
      

  5.   

    sql1:='select * from table1 where logdate= '+quotedstr('2002-3-1');
      

  6.   

    我后端的数据库目前使用的是access,不过以后要换用SQL server,不用引号是正确的,我试过了。
    quotedstr('2002-3-1');也是不正确的,可能在sql server中可以。我试过了。