Dbyte
Technical User
- Mar 6, 2002
- 87
Okay, so I read the FAQs on how to calculate age using a person's DOB. I also found an If/then statement to correct the ages of those born before 1930 (removes negative age values). What I need is 1 SQL statement that combines these 2 things. Here is my existing statement that calculates age (it's part of a LONG statement pulling many values from an existing table into a new table based on a date range selected by the user in a form):
(DateDiff("yyyy",([Date of Birth]),Date())+(Date()<DateSerial(Year(Date()),Month([Date of Birth]),Day([Date of Birth])))) AS Age INTO [Report Table]
How do I add the part about correcting the age of anyone born before 1930? Can it be done as part of this statement? Or do I need to run a 2nd query to update the Age value (in the new table) based on the following criteria:
If Age>=0 then Age, Else Age=100-ABS(Age)
Thanks in advance for any help.
(DateDiff("yyyy",([Date of Birth]),Date())+(Date()<DateSerial(Year(Date()),Month([Date of Birth]),Day([Date of Birth])))) AS Age INTO [Report Table]
How do I add the part about correcting the age of anyone born before 1930? Can it be done as part of this statement? Or do I need to run a 2nd query to update the Age value (in the new table) based on the following criteria:
If Age>=0 then Age, Else Age=100-ABS(Age)
Thanks in advance for any help.