这句sqlserver的Sql语句:
select count(*) from personschedule where dateadd(mi,-convert(int,pretime),convert(datetime,scheduleTimeB + ':00')) between '2003-5-13 16:50:03' and '2003-5-13 17:00:03' and UserId = '41'转到Access上应该怎么写?

解决方案 »

  1.   

    pretime:int字段
    scheduleTimeB string字段形如'2003-5-13 17:00''
      

  2.   

    SQL Server和Access时间格式表示方法不一样,
    在Access中应该为 #2003-5-13 17:00#,试试看
      

  3.   

    那么这句呢:
    dateadd(mi,-convert(int,pretime),convert(datetime,scheduleTimeB + ':00'))
      

  4.   

    select count(*) 
    from personschedule 
    where  (scheduleTimeB - cdate('00:' + cstr(pretime) + ':00')) between #2003-5-13 16:50:03# and #2003-5-13 17:00:03# and UserId = '41'没调试.
      

  5.   

    To  Quady515(柱子)
    谢谢,语法正确
    但如何使(scheduleTimeB - cdate('00:' + cstr(pretime) + ':00')) 减去的是日?
      

  6.   


    dateadd返回的是一个具体时间,
    用在这里不太明白具体意义?按照我以前的用法,
    比如查询最近一周的数据,
    数据库中表示时间的字段名为"采样时间"
    可以如下写SQL语句:dim strSQL as String
    dim StartTime As VariantStartTime = DateAdd("ww", -1, Date)
    strSQL="select * from 数据表 where 采样时间 between #"& _
        Format(Trim(StartTime), "yyyy/mm/dd hh:nn:ss") & "# " & _
        " and #" & Format(Now, "yyyy/mm/dd hh:nn:ss") & "#"
      

  7.   

    To  Quady515(柱子)
    有数据时候还是报:数据类型不匹配
      

  8.   

    谢谢treewith(开心~~一切从幼稚开始)
    怎样将String 型 scheduleTimeB ==〉日期型?
      

  9.   

    scheduleTimeB - cdate('0000/00/' + cstr(pretime) + ' 00:00:00')
    这个好更好用.
    DateAdd("d",cint(pretime),scheduleTimeB )
      

  10.   

    Quady515(柱子) 、treewith(开心~~一切从幼稚开始)请到:
    http://expert.csdn.net/Expert/topic/1778/1778219.xml?temp=.4668695
    继续接分