1、我在进行计算时,如果得到负数应该怎么让其显示在Label.caption中呢?我下面的代码为负数就出错了。
Label2.Caption:=IntToStr(StrToInt(srje.Caption)-StrToInt(kzje.Caption))+' 元';
2、下面是取当月现金的总和。不能显示结果,请达人指点。
with DataModule1.ADOfind do    
begin
close;
SQL.Clear;
SQL.Add('select Sum(dataMoney) as sr from data where ');
SQL.Add('datalx=''入帐'' and datadate between '+FormatDateTime('yyyy-mm-01',now)+ ' and ' +FormatDateTime('yyyy-mm-31',now));
Open;
end;label1.caption:=DataModule1.ADOfind.FieldByName('sr').Asstring + ' 元';

解决方案 »

  1.   

    SQL.Add('datalx=''入帐''   and   datadate   between   '+FormatDateTime('yyyy-mm-01',now)+   '   and   '   +FormatDateTime('yyyy-mm-31',now)); 这一段代码当中,传进去的SQL语句有两个日期数据,却变成了三个整形数据相减。个人建议可以加上一个引号。
    with   DataModule1.ADOfind   do         
    begin 
    close; 
    SQL.Clear; 
    SQL.Add('select   Sum(dataMoney)   as   sr   from   data   where   '); 
    SQL.Add('datalx=''入帐''   and   datadate   between   '''+FormatDateTime('yyyy-mm-01',now)+   '''   and   '''   +FormatDateTime('yyyy-mm-31',now)+''''); 
    Open; 
    end; label1.caption:=DataModule1.ADOfind.FieldByName('sr').Asstring   +   '   元';
      

  2.   

    2楼的方法使用后出错---------------------------
    Debugger Exception Notification
    ---------------------------
    Project Project1.exe raised exception class EOleException with message 'Data type mismatch in criteria expression'. Process stopped. Use Step or Run to continue.
    ---------------------------
    OK   Help   
    ---------------------------
      

  3.   

    什么数据库?什么DataDate的数据类型是什么?存储格式是什么?
      

  4.   

    Access2000       DataDate的数据类型是“日期”    存储格式是类似于 2007-06-22   这样的。
      

  5.   

    with   DataModule1.ADOfind   do         
    begin 
    close; 
    SQL.Clear; 
    SQL.Add('select   Sum(dataMoney)   as   sr   from   data   where   '); 
    SQL.Add('datalx=''入帐''   and   datadate   between   {'+FormatDateTime('yyyy-mm-01',now)+   '}   and   {'   +FormatDateTime('yyyy-mm-31',now)+'}'); 
    Open; 
    end; label1.caption:=DataModule1.ADOfind.FieldByName('sr').Asstring   +   '   元';