Brian Dunning's FileMaker Custom Functions

get_Generation

Find Generation

  Average rating: 4.4 (25 votes) Log in to vote

John Pollard   John Pollard
generic human studies
http://generichumanstudies.com

Share on Facebook Share on Twitter

  Sample input:
a birthday
  Sample output:
Baby Boomer

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Just a calc to determine what "generation" a person was born according to the marketing mode people. I hope it's right.

Given a nice tight edit by vr, who clarified some issues about it. I suppose I should fix the astrological one as well.



;-)

 

Comments

comment   comment, VR
Mar 22, 2015
The Case() function returns the result of the FIRST test that returns true - so you could shorten the whole thing to just:

Let (
y = Year ( birthday )
;
Case (
y < 1900 ; "Too old" ;
y ≤ 1945 ; "Silent Majority" ;
y ≤ 1954 ; "Baby Boomer" ;
y ≤ 1965 ; "Gen Jones" ;
y ≤ 1976 ; "Gen X, Lost" ;
y ≤ 1994 ; "Gen, Y, Millennial" ;
y ≤ 2006 ; "Gen Z" ;
"Too young"
)
)


Note:

1. Year (date) returns a number; to compare it with another year (also a number) you should not quote that number - otherwise the comparison will be alphabetical instead of numeric. Not critical when all numbers are four digits long, but still good practice.

2. The parentheses around the comparison are redundant;

3. You can save the repeated evaluation of Year ( birthday ) by storing it in a variable.
 
John   John
Mar 22, 2015
Hey VR,

I appreciate this. Could you work this magic on the astrological calc? So that's updated as well.

There's a year and month date, so i'm not sure what the approach would be there, but this sure is a cleaner version.

Many thanks,

JP
 
John   John
Mar 22, 2015
Old way it was, just for reference how not to do it.

Case( (Month(c0_person_birthday) = 3 and Day(c0_person_birthday) >= 21) or (Month(c0_person_birthday) = 4 and Day(c0_person_birthday) <= 19); "Aries";
(Month(c0_person_birthday) = 4 and Day(c0_person_birthday) >= 20) or (Month(c0_person_birthday) = 5 and Day(c0_person_birthday) <= 20); "Taurus";
(Month(c0_person_birthday) = 5 and Day(c0_person_birthday) >= 21) or (Month(c0_person_birthday) = 6 and Day(c0_person_birthday) <= 20); "Gemini";
(Month(c0_person_birthday) = 6 and Day(c0_person_birthday) >= 21) or (Month(c0_person_birthday) = 7 and Day(c0_person_birthday) <= 22); "Cancer";
(Month(c0_person_birthday) = 7 and Day(c0_person_birthday) >= 23) or (Month(c0_person_birthday) = 8 and Day(c0_person_birthday) <= 22); "Leo";
(Month(c0_person_birthday) = 8 and Day(c0_person_birthday) >= 23) or (Month(c0_person_birthday) = 9 and Day(c0_person_birthday) <= 22); "Virgo";
(Month(c0_person_birthday) = 9 and Day(c0_person_birthday) >= 23) or (Month(c0_person_birthday) = 10 and Day(c0_person_birthday) <= 22); "Libra";
(Month(c0_person_birthday) = 10 and Day(c0_person_birthday) >= 23) or (Month(c0_person_birthday) = 11 and Day(c0_person_birthday) <= 21); "Scorpio";
(Month(c0_person_birthday) = 11 and Day(c0_person_birthday) >= 22) or (Month(c0_person_birthday) = 12 and Day(c0_person_birthday) <= 21); "Sagittarius";
(Month(c0_person_birthday) = 12 and Day(c0_person_birthday) >= 22) or (Month(c0_person_birthday) = 1 and Day(c0_person_bi
 
unix   unix, Japan
Mar 22, 2015
use DayOfYear() and 1 somewhere for leap year.
 
comment   comment, VR
Mar 24, 2015
@John:
Join a forum, e.g. http://fmforums.com
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: