title

解决方案 »

  1.   

    对了,要先 Use DateUtils;
      

  2.   

    起用单元:DateUtils
    function DaysBetween(const ANow,AThen:TDateTime):integer;
    function dayspan(const ANow,AThen:TDateTime):Double;unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,DateUtils;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      i : Integer;
      f : Double;
    begin
      //获取两个日期的天数
      i := DaysBetween(Now-500,Now);
      Showmessage(IntToStr(i)); //500
      //获取两个日期的天数
      f := DaySpan(Now-500,Now);
      Showmessage(FloatToStr(f)); //500
    end;end.
      

  3.   

    var
       days:int;
     begin
        days:=trunc(date-strtodate('2002-1-1'));
      end;