Jump to content
Salesforce and other SMB Solutions are coming soon. ×

age with competition


mbk28
 Share

Recommended Posts

  • Gold Members

Hi,

I have many tables but 2 in use for age calculation: people and event

in the people I have the birthday and in the event I have the date of the event (olympics) and I try to find old is someone for an event.

In the file join, you can see the date of birthday, I use the 18/04/1994 not the 18 APR 1994 and the jourmed (day of event)

but sometime, I have problem with the February 29 if people born a year with feb 29, don't know how to solve the problem

 

I use this calculation:

// This is a Custom Function version of calculations provided in "Advanced FileMaker Pro 5.5" by Chris Moyer and Bob Bowers. This formula differs slightly from the ones in the book which do not account for leap years.

Definir ( leapFactor = Si ( Mod ( Annee ( theDate ) ; 4 )  = 0 ; 1 ; 0 ); Cas ( // Age in years Format = 1 ; Annee ( theDate ) - Annee ( Birth ) - ( ( JourAnnee ( theDate ) - leapFactor ) < JourAnnee ( Birth ) ); // Age in years and days Format = 2 ; Annee ( theDate ) - Annee ( Birth ) - ( ( JourAnnee ( theDate ) - leapFactor ) < JourAnnee ( Birth ) ) & " ans et " & Cas ( ( JourAnnee ( theDate ) - leapFactor ) ≥ JourAnnee ( Birth ) ; JourAnnee ( theDate ) - leapFactor - JourAnnee ( Birth )  ; JourAnnee ( theDate ) + ( JourAnnee ( Date ( 12 ; 31 ; Annee ( theDate ) ) - JourAnnee ( Birth ) - leapFactor ) ) ) & " jour(s)" ; // Age in years, months and days Format = 3 ;  Annee ( theDate ) - Annee ( Birth ) - ( ( JourAnnee ( theDate ) - leapFactor ) < JourAnnee ( Birth ) ) & " ans " & Mod ( Mois ( theDate ) - Mois ( Birth ) + 12 - (Jour ( theDate ) < Jour ( Birth ) ) ; 12 ) & " mois et " & (theDate - Date ( Mois ( theDate ) - (Jour ( theDate ) < Jour ( Birth ) ) ; Jour ( Birth ) ; Annee ( theDate ) ) ) & " jour(s)" ) )

Capture d’écran 2018-04-20 à 09.34.38.png

Link to comment
Share on other sites

  • Gold Members

it's the same calcul if he (she) win the gold medal

each event have it's date (jourmet), games are on 15 days with medal every days

Link to comment
Share on other sites

A long discussion on FileMaker Community has your calculation near the beginning of the thread, and ends with this one

Let(
    [
        cd = Get( CurrentDate );
        dob = Birthdate
        //for leapers: choose 1 to birthday on 28 february or 0 to 1st march in non leap year
        leaper = 1;
        /*leap year : this calculation is more certain because it does not just divide by 4 > see algorithm in      https://en.wikipedia.org/wiki/Leap_year#Leap_day lets filemaker do the calculataion itself */
        LY_test = ( Month( date( 2; 29; Year( cd ) ) ) = 2 );
        //birthday  (usually those born on February 29 celebrating their birthday on the 28th of the month)-------------------------
        bd =
        if(
            Month( dob ) & Day( dob ) = 229 and LY_test = 0 and leaper = 1;
            Date( 2; 28; Year( cd ) );
            Date( Month( dob ); Day( dob ); Year( cd ) )
        );
        //calculation----------------------------------------------------------------------------------------------------------------------------------
        years = Year( cd ) - Year( dob ) - ( cd < bd );
        months =
        case(
            cd = bd;
            "";
            cd < bd;
            12 - Month( dob ) + Month( cd ) - 1;
            cd > bd and Month( cd ) - Month( bd ) > 1 and Day( cd ) < Day( bd );
            Month( cd ) - Month( bd ) - 1;
            cd > bd and Day( cd ) ≥ Day( bd );
            Month( cd ) - Month( bd )
        )
    ];
    years & " Year" & if( years > 1; "s" ) & " " &
    Case( months > 0; months & Case( months = 1; " Month"; " Months" ) )
)

In the future please do enclose your code in Code <> tags for easier readability

  • Like 1
Link to comment
Share on other sites

I would just use the calculation AgeInDays = DateCompetition -  DateOfBirth.  Calculate an acceptable range of days "days alive" based upon age of contestants.

Link to comment
Share on other sites

 Share



×
×
  • Create New...

Important Information

Terms of Use