miércoles, 15 de octubre de 2008

Calcular la Edad (en años) segun la fecha de nacimiento

edad_cinturon
procedure TForm1.Button1Click(Sender: TObject);

function Edad(FechaNacimiento:string):integer;
var
iTemp,iTemp2,Nada:word;
Fecha:TDate;
begin
Fecha:=StrToDate(FechaNacimiento);
DecodeDate(Date,itemp,Nada,Nada);
DecodeDate(Fecha,itemp2,Nada,Nada);
if FormatDateTime('mmdd',Date) <
FormatDateTime('mmdd',Fecha) then Result:=iTemp-iTemp2-1
else Result:=iTemp-iTemp2;
end;

begin
Label1.Caption:=intToStr(Edad('07/09/1969'));
end;

No hay comentarios: