سلام
این تابع رو خودم نوشتم. ببین بدرد میخوره؟
function TfrmMain.Duration(y1,m1,d1,y2,m2,d2:Integer):Integ er;
var
day:integer;
begin
day:=d2-d1;
if m2>m1 then
begin
if m2<7 then
day:=31-d1+d2+(m2-m1-1)*31;
if m1>6 then
day:=30-d1+d2+(m2-m1-1)*30;
if (m2>6) and (m1<=6) then
day:=31-d1+(6-m1)*31+(m2-7)*30+d2;
end;
if y2>y1 then
begin
if y1 mod 4=3 then
begin
if (m1<7) and (m2<7) then
day:=31-d1+(6-m1)*31+180+(m2-1)*31+d2;
if (m1<7) and (m2>6) then
day:=31-d1+(6-m1)*31+180+186+(m2-7)*30+d2;
if (m1>6) and (m2<7) then
day:=30-d1+(12-m1)*30+(m2-1)*31+d2;
if (m1>6) and (m2>6) then
day:=30-d1+(12-m1)*30+186+(m2-7)*30+d2;
end
else
begin
if (m1<7) and (m2<7) then
day:=31-d1+(6-m1)*31+179+(m2-1)*31+d2;
if (m1<7) and (m2>6) then
day:=31-d1+(6-m1)*31+179+186+(m2-7)*30+d2;
if (m1>6) and (m2<7) then
day:=30-d1+(12-m1)*30-1+(m2-1)*31+d2;
if (m1>6) and (m2>6) then
day:=30-d1+(12-m1)*30-1+186+(m2-7)*30+d2;
end
end;
result:=day;
end;