digits997
01-01-2008, 06:49 AM
I am doing a database containing names, dates of birth, dates of death etc of my ancestors. Does anyone know the best way of displaying it so I can sort them out by age of death? For example, I want to see someone for example who died aged 70 years and 6 months to be a place above someone who died aged 70 years and 4 months.
jdraw
01-01-2008, 07:55 AM
digits997,
Since I don't know the fields in your table, I am using a table called Ancestor with fields Name, BirthDate and DeathDate. BirthDate and DeathDate are Date/Time datatypes.
I think what you are looking for is a query that will sort based on the value between Birthdate and Deathdate. There is a function called DateDiff which can help you.
A query similar to this will list the "Ancestor Names" in the AgeAtDeath order with the "largest value" first.
SELECT ancestor.name
, ancestor.birthdate
, ancestor.deathdate
, DateDiff("d",[birthdate],[deathdate]) AS ageAtDeath
FROM ancestor
ORDER BY DateDiff("d",[birthdate],[deathdate]) DESC;