Question : Delphi Age between two dates returned as year and months

Can somwebody please help. I need to calulate age in not only years but months too.

I have a D.O.B and a Risk Start Date (any date in the future).

I have found many examples of just the Years being calculated but cannot find code to calulate the months too.

Please Help!!!

Alan

Answer : Delphi Age between two dates returned as year and months

I have used dateutils unit with methods YearsBetween and MonthsBetween, I have also put 2 TDateTimePickers on my form with names Date1 and Date2:
1:
2:
3:
4:
5:
6:
7:
8:
var
  years, months : integer;
begin
  years := YearsBetween(Date1.Date, Date2.Date);
  months := MonthsBetween(Date1.Date, Date2.Date) - years * 12;
  showmessage(inttostr(years));
  showmessage(inttostr(months));
end;
Random Solutions  
 
programming4us programming4us