Search for Living Relatives born after a certain date

31 views
Skip to first unread message

daa

unread,
Jun 24, 2011, 11:42:48 AM6/24/11
to GEDitCOM II Discussions
I thought I could do this in the older version and I tried again late
last night and could not figure it out. I want to search for people
that were born after a certain date (that's easy), who are still
living (I'm not sure what to to search for there).

daa

unread,
Jul 3, 2011, 1:59:31 PM7/3/11
to geditcom-ii...@googlegroups.com
OK, so I have been looking at some of the canned scripts and have come up with the following (snippet from a longer version) that works, almost, it gets dates in the 1800's. I'm a little confused as to how the dates are handled apparently. Any ideas?

tell item i of indisRef

set bday to birth date

if bday > "01 01 1915" then

if death date = "" then

set theLine to {first name, middle name, surname, life span} of item i of indisRef

copy theLine to the end of indi_list

end if

end if

end tell


I was also playing around with this:


tell item i of indisRef

--set bdate to (date year of birth date)

--if bdate > "1915" then

set bdate to birth date

if bdate > "01 01 1915" then

if death date = "" then

--set ddate to date today

set age to (birth SDN - death SDN) / 365.25

if age > 80 then

set theLine to {first name, middle name, surname, life span} of item i of indisRef

copy theLine to the end of indi_list

end if

end if

end if

end tell

Nairn John

unread,
Jul 4, 2011, 10:37:06 AM7/4/11
to geditcom-ii...@googlegroups.com
I am not exactly sure what the goal of the scripts are, but I expect you are not getting what you want with comparisons like

if bday > "01 01 1915" then

This is doing a string comparison and Apple Script will not recognize the strings as dates and therefore will not compare them as dates; they will rank in alphabetical order. Furthermore, the property "birth date" will return the date in GEDCOM format so it will be something like "12 NOV 1934" and not numbers (you can get numbers if you want by using date format conversions).

If you are trying to do date comparisons, you should always be using date SDNs (for serial day numbers). These are day numbers assigned to dates (starting from about 4000 BC). You can compare SDNs (because they are numbers) and it will work for any calendar (because the date is converted to a number). You probably want something like

set sdnRange to sdn range full date "1 JAN 1915"
set minSDN to item 1 of sdnRange
tell item i of indisRef
    set bday to birth SDN
    if bday >= minSDN
        -- this person has a valid birth date that is after or on 1 JAN 1915
        -- do any desired calculations
    end if
end tell

I did not test this in Script editor, but I think the basic ideas are correct. The first line converts date "1 JAN 1915" to an sdnRange in a list. Since it is an exact date, the list will have two identical numbers. The next line loads the first item into a variable. Now when looking at the individual, grab the birth SDN (and not the date text). This SDN can be compared to the one calculated in minSDN. If the birth date is not an exact date (e.g., 1934), the "birth SDN" property will give the minimum possible SDN (for "1934" it would be SDN for "1 JAN 1934). If it matters, you can retrieve the "birth SDN max" as well which has the maximum possible SDN for non-exact dates (for "1934" it would be SDN for "31 DEC 1934").

The second script also has some errors. It does an age calculation only if death date is empty. But that means there is no death date. The property death SDN will therefore return 0 (which for SDNs means no date or an invalid date). The age calculation will thus give birth SDN/365.25 which will always be very large numbers (around 6000 for people born in 20th century).

Once inside the conditional (as corrected above) you probably want

set dday to death date SDN
if dday > 0 then
    set age to (dday - bday) /  365.25
    if age > 0 then
        -- thus person has known birth and death dates and was over 80 at death
    end if
end if

For a refinement, you might want to use (death SDN max - birth SDN) / 365.25, which will catch everyone that could have been 80 when they died (i.e., age calculated from maximum number of days they were alive based on recorded date information). Or possibly (death SDN - birth SDN max) / 365.25 , which will only catch those that were certainly over than 80 based on records date information (i.e., age calculated from minimum possible days they were alive).

To see some date calculations in action, you can look at the "Age Analysis Report" script (you can open it for viewing by selecting in from the scripts menu in GEDitCOM II while holding down the option key).
------------
John Nairn
Genealogy Software for the Mac

daa

unread,
Jul 5, 2011, 12:32:08 AM7/5/11
to GEDitCOM II Discussions
Thanks for the help, I realized I was not getting the date format
correct, and your explanation helped. What I want to do is in the
title. I want to have some rough idea of who in my file is still
living who was born after a certain date. I want to go and knock on
their door and before they go knock on theirs and update their file. I
added a max conditional so I don't get everyone after a certain date.
I realize it isn't perfect: if I don't have a death date updated, it
will still show up in the report, the dates are hard coded in the
script, and it might be nice to somehow check for the "has died" flag,
its kinda slow writing the report, but it isn't the kind of script I
will be running very often so I just want to get in the ballpark.
Anyway I now have "snippet":

set sdnminRange to sdn range full date "1 JAN 1915"
set sdnmaxRange to sdn range full date "1 JAN 1940"
set minSDN to item 1 of sdnminRange
set maxSDN to item 1 of sdnmaxRange

repeat with i from 1 to numIndis
tell item i of indisRef
set bday to birth SDN
set dday to death SDN
if bday ≥ minSDN and bday ≤ maxSDN then
if dday = 0 then
set theLine to {first name, middle name, surname, life span} of
item i of indisRef
copy theLine to the end of indi_list
end if
end if
end tell
etc.

It appears to work, if anything still looks odd I can change it. This
is using the Age Analysis script of yours, BTW. I can send you the
entire file, but I doubt it will be of much use to anyone. Anyway it
was good practice. DAA
> John Nairnhttp://www.geditcom.com

Simon Robbins

unread,
Jul 5, 2011, 3:13:42 AM7/5/11
to GEDitCOM II Discussions
Try this, it should exclude those with no death date but where the
"has died" flag is ticked


tell application "GEDitCOM II"
set sdnminRange to sdn range full date "1 JAN 1915"
set sdnmaxRange to sdn range full date "1 JAN 1940"
set minSDN to item 1 of sdnminRange
set maxSDN to item 1 of sdnmaxRange
set indi_list to {}
set indisRef to every individual of front document
set numIndis to number of items in indisRef
repeat with i from 1 to numIndis
tell item i of indisRef
set bday to birth SDN
set dday to death SDN
try
set hasdied to contents of structure named "DEAT"
on error
set hasdied to "?"
end try
if bday ≥ minSDN and bday ≤ maxSDN then
if dday = 0 or hasdied = "Y" then
set theLine to {first name, middle name, surname, life span} of
item i of indisRef
copy theLine to the end of indi_list
end if
end if
end tell

end repeat
end tell

Simon Robbins

unread,
Jul 5, 2011, 3:18:58 AM7/5/11
to GEDitCOM II Discussions
Oh dear, I haven't really woken up yet. it should of course be '
hasdied is not "Y" ' to exclude the deceased individuals.

Achterberg David

unread,
Jul 5, 2011, 11:55:35 AM7/5/11
to geditcom-ii...@googlegroups.com
You had it closer to what I wanted in your original version. I had to
clean up my file a little. If there was a source and/or a place
attached to a death event, without a death date and the "as died" flag
was not checked, it was shown in the report as 1920-? for example. So
I flagged those indi as had died and changed the script as below, and
it seems to work.

tell item i of indisRef
set bday to birth SDN
set dday to death SDN
try
set hasdied to contents of structure named "DEAT"

if hasdied = "Y" then set dday to "0" --filter out "has died"
on error
set hasdied to "X" --set hasdied to "?"
end try
if bday ≥ minSDN and bday ≤ maxSDN then -- has a valid birth
date that is after or on sdnminRange and is before or on sdnmaxRange
if dday = 0 then --or hasdied = "Y" then


set theLine to {first name, middle name, surname, life span} of
item i of indisRef
copy theLine to the end of indi_list
end if
end if
end tell

Reply all
Reply to author
Forward
0 new messages