帖一个函数:
function MonthDays(const YearInt,MontInt:Word):byte;
begin{返回指定年月的天数}
case MontInt of
1,3,5,7,8,10,12: Result:=31;
4,6,9,11: Result:=30;
2: case IsLeapYear(YearInt) of
true: Result:=29; {闰年}
else Result:=28;
end;
else Result:=0;
end;
end;
function DateNew(
const Dateset:string;
const yearSet,montSet,daysSet:integer):string;
var
intYear,intMont,intDays,intTemp :word;
begin{旧日期加日期得到新日期}
try
decodeDate(strtoDate(Dateset)+daysSet, intYear,intMont,intDays);
intYear:=((intMont +montSet-1) div 12) +intYear +yearSet;
intMont:=((intMont +montSet-1) mod 12) +1;
intTemp:= MonthDays(intYear, intMont);
if(intTemp < intDays) then
begin
inc(intMont);
intYear := intYear +integer(intMont>12);
intMont :=((intMont -1) mod 12) +1;
intDays :=((intDays -1) mod intTemp) +1;
end;
result := datetostr(encodeDate(intYear, intMont, intDays));
except
result := Dateset;
end;
end;