我两个日期型变量A='2001-1-1',B='2002-2-22';
如何判断 A-B>1年(即A与B是否相差一年)
如何判断 A-B>1年(即A与B是否相差一年)
解决方案 »
- ClientDataSet1控件怎么删除数据?
- dxMasterView控件,如何根据条件来让记录显示不同的颜色。
- 千金散去还复来。。
- 初学类,问个基础问题.
- 感谢ARI的帮忙
- VOD多媒体视频点播系统
- 今天是我生日,本来可以高高兴兴过的,可是早上陪女朋友去医院,发现她的眼角膜有问题,拿出我所有的30份,为她祝福早点康复,Delphi版的
- 请问想hook住另外一个进程的WM_COMMAND消息应该用哪种钩子类型?
- 急(送100分):多个image控件如何用imagexxx使用?
- 关于MessageBox的小问题??
- 自动调整窗口的大小?(给50分,在线等)
- Delphi大联盟-(最好的讨论,求助QQ群 号码:1463857)
DataSp:Integer;
A,B:string;
...
DataSP:=strtodate(A)-strtodate(B);
if DataSP>365+366 then
showmessage('超过两年');
Date1, Date2: TDate;
Y1, M1, D1, Y2, M2, D2, Y, M, D: Word;
begin
Date1 := StrToDate('2001-1-1');
Date2 := StrToDate('2002-2-22');
DecodeDate(Date1, Y1, M1, D1);
DecodeDate(Date2, Y2, M2, D2);
Y := Y2 - Y1;
M := M2 - M1;
D := D2 - D1;
if (Y > 1)
or ((Y = 1) and (M > 0))
or (((Y = 1) and (M = 0)) and (D > 0)) then
ShowMessage('Date2>Date1');
end;————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
begin
n:=yearsbetween(DateTimePicker1.DateTime,DateTimePicker2.DateTime);
edit1.Text:=inttostr(n);
var
a,b:string;
begin
a:=FormatDateTime('yyyymmdd',DateTimePicker1.Date);
b:=FormatDateTime('yyyymmdd',DateTimePicker2.Date);
if copy(a,1,4)=copy(b,1,4) then
begin
showmessage('一样的!:)');
end else showmessage('不一样的!:(');
end;
DataSp:Integer;
A,B:string;
...
DataSP:=strtodate(A)-strtodate(B);
if DataSP>365+366 then
showmessage('超过两年');
var
a,b:Tdate;
begin
A:=strtodate('2001-1-1');
B:=strtodate('2002-1-1');
if (b-a)>=365 then showmessage('大于一年');end;