|
Increases or decreases the month part of a given date |
|
date |
the date to convert |
number |
numbers of months to add or subtract |
|
external function Boolean GetPD (var record PDVc);
global
procedure CalcDueDate(string paydeal,Date tdp,var Date resp)
BEGIN
record PDVc PDr;
LongInt restdays;
resp = tdp;
PDr.Code = paydeal;
if (GetPD(PDr)) then begin
resp = AddDay(tdp,PDr.pdays);
switch (PDr.PDType) begin
case 4:
resp = tdp;
resp = AddMonth(resp,1);
if (PDr.pdays==0) then begin
resp = AddMonth(resp,1);
end;
resp = AddDay(resp,-GetDay(resp) + 1);
restdays = DateDiff(resp,tdp);
if (PDr.pdays>=0) then begin
restdays = restdays - 1;
end;
restdays = PDr.pdays + restdays;
resp = AddDay(tdp,restdays);
end;
end;
RETURN;
END;
««