我在delphi 7 中执行如下sql 数据库是access2000格式Select sum(TotalPrice) as SumPrice From VTotalPrice Where OrderDate between #2003-06-03 00:01:00# and #2003-06-03 23:59:59#报错:不正常的定义参数对象,提供了不一致或不完整的信息。我查阅了前面的提问,说 access在操作日期型数据的时候要加#,加上还是不对。其实我就是想得到某天金额的总和,access操作日期型数据怎么这么别扭??!!

解决方案 »

  1.   

    只要能实现查找当天的数据就可以了,access有能run sql的地方嘛?
      

  2.   

    Select sum(TotalPrice) as SumPrice From VTotalPrice Where OrderDate between #2003-06-03 00:01:00.001# and #2003-06-03 23:59:59.999#
    这样呢?
      

  3.   

    access有能运行sql的地方。左边的菜单,对象->查询->创建查询->关闭->右击->SQL视图
      

  4.   

    Select sum(TotalPrice) as SumPrice From VTotalPrice Where OrderDate between '2003-06-03 00:01:00.001' and '2003-06-03 23:59:59.999'
    不过建议最好用参数吧!
      

  5.   

    怪了,我在access里面执行
    Select sum(TotalPrice) as SumPrice From VTotalPrice Where OrderDate between #2003-06-03 00:01:00# and #2003-06-03 23:59:59#是没有问题的。但是放到delphi 7里面却不行。代码如下:  DBWin.RS1.Active:=false;
      DBWin.RS1.CommandText:='Select sum(TotalPrice) as SumPrice From VTotalPrice Where OrderDate between #2003-06-03 00:01:00# and #2003-06-03 23:59:59#'
      DBWin.RS1.Active:=true;
      Edit6.Text:=DBWin.RS1.FindField('SumPrice').AsString;
      

  6.   

    SumPrice是你定義的?
    如果是加總的話,應該是column1呀
    你用的是甚麼控件?
    我用query實現的時候,系統自動分配column1這個字段名的
      

  7.   

    用day month year函数算了。多方便
      

  8.   

    DBWin.RS1.Active:=false;
      DBWin.RS1.CommandText:='Select sum(TotalPrice) as SumPrice From VTotalPrice Where OrderDate between #2003-06-03 00:01:00# and #2003-06-03 23:59:59#';
      DBWin.RS1.Active:=true;
      Edit6.Text:=DBWin.RS1.FindField('SumPrice').AsString;我这么写错那里了??报错:不正常的定义参数对象,提供了不一致或不完整的信息。
      

  9.   

    DBWin.RS1.Active:=false;
      DBWin.RS1.CommandText:='Select sum(TotalPrice) as SumPrice From VTotalPrice Where OrderDate > #6/2/2003 00:00# ';
      DBWin.RS1.Active:=true;
      RzEdit6.Text:=DBWin.RS1.FindField('SumPrice').AsString;
      DBWin.RS1.Active:=false;这样也不行………………呜呜呜怎么办??!!
      

  10.   

    用like查询, 只输日期,不用时间,应该行吧,把数据库里的当字符串'2003-06-20'
      

  11.   

    你的说的在sqlserver中也许还行,但是access就是不行di还有办法吗?
      

  12.   

    Select sum(TotalPrice) as SumPrice From VTotalPrice Where OrderDate between 
    #2003-06-03# and #2003-06-04#得到的不就是2003-06-03的總和了
      

  13.   

    c_time:=DateTimePicker3.Date+StrToDateTime(' 00:00:00');//---起始时间
      d_time:=DateTimePicker4.Date+StrToDateTime(' 23:59:59');//---结束时间
              with Query2 do //---查询book_Lend里的记录!
                begin
                  Close;
                  SQL.Clear;
                  SQL.Add('Select * from book_Lend where book_arrange Like :t1 and ((book_lend_date Between :t2 and :t3) or (Book_return_date between :t4 and :t5))');
                  Parameters[0].value:=a+'%';
                  Parameters[1].Value:=c_time;
                  Parameters[2].Value:=d_time;
                  Parameters[3].Value:=c_time;
                  Parameters[4].Value:=d_time;
                  Open;
                  b:=IntToStr(RecordCount);我程序里的一段你看看
      

  14.   

    Select sum(TotalPrice) as SumPrice From VTotalPrice Where OrderDate between 
    '2003-06-03' and '2003-06-04'
      

  15.   

    我用delphi 7 + access 2000 
    SQL语句中用 WHERE 日期 >= #2003-4-13# AND 日期 <= #2003-6-19# 
    这样的语句是可行的