AgeAtDateInWeeks Function
Returns the Age (in weeks) of a "person" given their Date of Birth (DOB) and the Date of Reference (DT).

Unit
QESBPCSDateTime

Declaration
Function AgeAtDateInWeeks(const DOB, DT: TDateTime): Integer;

Description
If DT occurs before DB then -1 is returned. Routine donated by David Gobbett.

Parameters
DOB Date of Birth.
DT Date in question.

Returns
Age in Integral Weeks at the Date in question.

Category
Date/Time Arithmetic Routines
Week Based Arithmetic Routines

Implementation

function AgeAtDateInWeeks (const DOB, DT: TDateTime): Integer;
begin
     if DT < DOB then
          Result := -1
     else
     begin
          Result := Trunc (DT - DOB) div 7;
     end; {else}
End;


HTML generated by Time2HELP
http://www.time2help.com