Report: Ages of people when they died

From TNG_Wiki
Jump to navigation Jump to search

Description: Ages of people when they died, replace "savenije" with the name of your gedcom or tree


Copy and paste the text between the lines into the reports section below "OR Leave Display, Criteria and Sort fields blank and enter direct SQL SELECT statement here:" and give it the title you think is appropriate, this report also gives the age in format X year, Y months, Z days


SELECT personid, lastname, firstname, birthdate, deathdate, gedcom, @years  := year( @adt  := if( deathdatetr, replace( deathdatetr,  '-00',  '-01'  ) , 
curdate(  )  )  )  - year( @abd  := replace( birthdatetr,  '-00',  '-01'  )  )  - ( mid( @adt , 6, 5  )  < mid( @abd , 6, 5  )  )  AS years, 
@months  := ( mid( @adt , 6, 5  )  < mid( @abd , 6, 5  )  )  *12 + month( @adt  )  - month( @abd  )  - ( day( @adt  )  < day( @abd  )  )  AS months, 
@days  := day( @adt  )  - day( @abd  )  + ( day( @adt  )  < day( @abd  )  )  * day( last_day( @adt  -  INTERVAL 1 
MONTH  )  )  AS days, @ca  := ( birthdatetr != @abd 
OR (
deathdatetr != @adt 
AND  NOT living
) )  AS about, concat( convert( @years , char ) ,  ' year, ', convert( @months , char ) ,  ' months, ', convert( @days , char ) , if( @ca ,  'd (about)',  ' days'  )  )  AS Age, living
FROM tng_people
WHERE gedcom =  'savenije'
AND deathdate !=  "y"
AND birthdatetr
AND (
deathdatetr
OR living
)
ORDER  BY Years DESC , Months DESC , Days DESC , lastname, firstname