Mate, this is always easy.
calculate the days from Day Zero. At least roughly.
you'll need a variable capable of storing quite a huge number.
How many days have passed from Day Zero to the date in Field #1?
roughly: 1977*365 (days in a year) + 11*30(days in a month) + 18;
there is your number1
calculate the other number as well.
subtract (any one of these from the other one) and use ABS function to get rid of the minus sign. There is the number of DAYS between those two dates.
Practically, all you need to find out the age is DIVIDE the number of days by 365 and you'll get the age and some decimals that you won't need. This will work quite well; hey- and if there really is some need for even more precission, use decimals in your calculations. (like a year has actually 365.25 days, as there are 365 days and 6 hours in a year, not every month has 30 days... and so on... but practically this should work just fine for the purpose)
[even though there ARE easier ways of obtaining the number of days between the two dates...]
Oh, OK, I'll give full details, as I have really nothing to do...
The TDateTime type consists of two parts: Date (stored as the integer part of a real value) [decimal point] Time (stored in the decimals) You can get at the DATE part of it by simply rounding the real value DOWN. Use FLOOR function (if available) to get just the integer value of your DateTime-type variable. Don't worry too much what exctly this number stands for, as there is no need to know (it's actually number of days passed since 1.1.1850 I think...) Rounding down both of your variables with the DateTime-s stored in them, you will get what you need to ABS(D1-D2) and then calculate the number of years from the Day delta you get.
code would look like this:
moment1,moment2:TDateTime;
d1,d2,DeltaD, AGE: integer;
d1 := floor(moment1);
d2 := floor(moment2);
DeltaD := ABS (d1-d2);
AGE := floor(deltaD / 365.25); // very precise calculation - note the floor function as we don't want to add any unwanted years of age to a person