S
skrysiak
is there any way to calculate age from 2 date fields in years
skrysiak said:is there any way to calculate age from 2 date fields in years
James A. Fortune said:skrysiak said:is there any way to calculate age from 2 date fields in years
For the age in years from dt1 to dt2 I use (VBA):
intCurrentAge = Int(Format(dt2, "yyyy.mmdd") - Format(dt1, "yyyy.mmdd"))
In SQL:
SELECT Int(Format(Date(), "yyyy.mmdd") - Format([BirthDate],
"yyyy.mmdd")) As CurrentAge FROM MyTable WHERE BirthDate IS NOT NULL;
It makes use of a mathematical concept known as a Poset (Partially
Ordered Set) relationship where the relative order of dates making up
the actual fraction of years is the same as the numerical order of the
pseudodecimal representation of those dates given by the format function.
James A. Fortune
[email protected]
MaRSMAN said::
skrysiak said:is there any way to calculate age from 2 date fields in years
For the age in years from dt1 to dt2 I use (VBA):
intCurrentAge = Int(Format(dt2, "yyyy.mmdd") - Format(dt1, "yyyy.mmdd"))
In SQL:
SELECT Int(Format(Date(), "yyyy.mmdd") - Format([BirthDate],
"yyyy.mmdd")) As CurrentAge FROM MyTable WHERE BirthDate IS NOT NULL;
It makes use of a mathematical concept known as a Poset (Partially
Ordered Set) relationship where the relative order of dates making up
the actual fraction of years is the same as the numerical order of the
pseudodecimal representation of those dates given by the format function.
James A. Fortune
[email protected]
How would the sql look if current age I want to show 60 years,10 months,3
days