Automatically calculate years to two decimals lazarus / 16-Databases ---------------------------------------------------------------------- Thomas Colvin · 2014-01-10 19:02 Have a table I'm useing. One column is date of birth and second column is age. How do I get it to automatically calculate and enter the age to two decimal places when I put in the birth date? Thanks, Thomas ---------------------------------------------------------------------- BlueIcaro · 2014-01-10 20:42 I don't understand your question. But you can take a look to DateUtil unit. Here: http://www.freepascal.org/docs-html/rtl/dateutils/index-5.html Where you will find the functions and procedures to work with dates, that comes with lazarus/freepascal /BlueIcaro ---------------------------------------------------------------------- howardpc · 2014-01-10 22:29 Assuming your 'table' is a TStringGrid with column 0 a Date of birth and column 1 the desired Age, then this OnEditingDone event handler will give you an (approximate) age: Code: [Select]uses dateutils, sysutils; procedure TForm1.ageGridEditingDone(Sender: TObject); var   d: TDateTime;   days: integer;   age: single; begin   if (ageGrid.Col=0) and     TryStrToDate(ageGrid.Cells[ageGrid.Col, ageGrid.Row], d) then begin       days:= DaysBetween(Now, d);       age:=days/365.25;       ageGrid.Cells[ageGrid.Col+1, ageGrid.Row]:=FormatFloat('##.##',age);     end; end;