| AgeAtDate Function |
Unit
QESBPCSDateTime
Declaration
Function AgeAtDate(const DOB, DT: TDateTime): Integer;
Description
If DT occurs before DB then -1 is returned.
| Parameters |
| DOB | Date of Birth. |
| DT | Date in question. |
Returns
Age in Integral Years at the Date in question.
Category
Date/Time Arithmetic Routines
Year Based Arithmetic RoutinesImplementation
function AgeAtDate (const DOB, DT: TDateTime): Integer;
var
D1, M1, Y1, D2, M2, Y2: Integer;
begin
if DT < DOB then
Result := -1
else
begin
OptDecodeDateI (DOB, Y1, M1, D1);
OptDecodeDateI (DT, Y2, M2, D2);
Result := Y2 - Y1;
if (M2 < M1) or ((M2 = M1) and (D2 < D1)) then
Dec (Result);
end;
End; |
|
|