Hace aproximadamente un mes un compañero solicitó el código para calcular Dias360 tál como lo hace Excel u OpenOffice.
En ese momento realizé un código que funcionaba sólo con el método NASD, pero no contemplaba el método europeo.
Pongo a disposición el código que contempla ambos métodos:
Código Delphi
[-]
function Dias360(FechaIni,FechaFin: TDate; NASD:Boolean): Integer;
var
ai,mi,di,
af,mf,df: Word;
begin
DecodeDate(FechaIni, ai, mi, di);
DecodeDate(FechaFin, af, mf, df);
if NASD then begin
if (di = 31) or ((mi = 2)and(di > 27)) then di:= 30;
if (df > 27)and(mf = 2) then df:= 30;
if (df = 31)and(di < 30) then
begin
Inc(mf);
df:= 1;
end
else if df = 31 then
df:= 30
end
else begin
if (di = 31) or ((mi = 2)and(di > 27)) then di:= 30;
if (df = 31) or ((mf = 2)and(df > 27)) then df:= 30;
end;
if Abs(af - ai) = 0 then
Result:= (mf-mi)*30 + df-di
else
Result:= Abs(af-ai-1)*360 + 360-mi*30 + 30-di + 30*(mf-1) + df
end;
Un ejemplo de llamada:
Código Delphi
[-]
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
Panel1.Caption:=IntToStr(Dias360(dtPicker1.Date, dtPicker2.Date,
not Boolean(ComboBox1.ItemIndex)));
end;
Espero les sea de utilidad.
Saludos.