Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

星期五, 11月 16, 2007

日期相差多少年、月、日、時、分、秒


procedure TForm1.BitBtn1Click(Sender: TObject);
var
a,b: Tdatetime;
c: string;
begin
a:=2007/3/13;
b:=2006/3/2;
c := '';
if (daysbetween(a,b) div 30) <> 0 then
c := inttostr(daysbetween(a,b) div 30)+'個月';

if ((daysbetween(a,b) mod 30) <> 0)and ((daysbetween(a,b) div 30) <> 0)then
c := c + '又' + inttostr(daysbetween(a,b) mod 30)+'天'
else if (daysbetween(a,b) mod 30) <> 0 then
c := inttostr(daysbetween(a,b) mod 30)+'天';

showmessage(c);
showmessage(inttostr(yearsbetween(a,b))+'年');
showmessage(inttostr(monthsbetween(a,b))+'月');
showmessage(inttostr(daysbetween(a,b))+'天');
showmessage(inttostr(hoursbetween(a,b))+'小時');
showmessage(inttostr(minutesbetween(a,b))+'分鐘');
showmessage(inttostr(secondsbetween(a,b))+'秒');
end;

沒有留言: