我在程序中要直接取本机的时间跟数据库中表中某条记录中的时间做比较,请问如何取这个本机时间,
 我用的SQL语句如下:
 select c.id,c.name
 from sheet_items s left join custom c on 
 s.custom=c.id
 where s.room='001'
 and s.start_time<"now"
 and s.end_time>"now"提示错误为:Syntax error converting datetime from character string.

解决方案 »

  1.   

    使用参数where s.room='001'
     and s.start_time<:aa
     and s.end_time>:bb
    parameters.parambyanme(‘aa’).value:=datatime(now)
      

  2.   

    select c.id,c.name
     from sheet_items s left join custom c on 
     s.custom=c.id
     where s.room='001'
     and s.start_time<now()
                      -----
     and s.end_time>now()
                    -----
    now()是取得当前时间的函数,DATE()是取得当前日期的函数,是SQL中的函数,ACCESS与SQL SERVER可用
      

  3.   

    如果是得到当前的日期进行比较的话可以用getdate()但是不是时间!还是用参数吧!
      

  4.   

    你问题的错误提示的原因是你把"NOW"这个字符串赋给了日期时间类型的字段。
    另外,我上面有个错误,就是在SQL SERVER中获取当前日期及时间的函数应该是GetDate()。