delphi 两个edit 内的时间相减得出天数,急急急
三个edit,edit1和edit2,里各有一个日期,日期格式为yyyy-mm-dd,edit3里显示1和2相减得到的天数,求教!求写的全一点...
三个edit,edit1和edit2,里各有一个日期,日期格式为yyyy-mm-dd,edit3里显示1和2相减得到的天数,求教!
求写的全一点 展开
求写的全一点 展开
2个回答
2015-01-14
展开全部
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,dateutils;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
s1,s2:string;
t1,t2:tdatetime;
d:int64;
begin
s1:=edit1.Text;
s2:=edit2.Text;
t1:=strtodatetime(s1);
t2:=strtodatetime(s2);
d:=trunc(dayspan(t2,t1));
edit3.Text:=inttostr(d);
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,dateutils;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
s1,s2:string;
t1,t2:tdatetime;
d:int64;
begin
s1:=edit1.Text;
s2:=edit2.Text;
t1:=strtodatetime(s1);
t2:=strtodatetime(s2);
d:=trunc(dayspan(t2,t1));
edit3.Text:=inttostr(d);
end;
end.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询