3 Replies Latest reply on Jun 20, 2014 9:40 AM by philmodjunk

    Need to generate list of Under 21 from DOB category

    MaryMurray

      Title

      Need to generate list of Under 21 from DOB category

      Post

           Hi,

            

           New to File Maker Pro.

            

           I'm working to generate a list of students who are Under 21 years of age. I currently have a layout that gives me their name and DOB.  How do I ask FMP to generate a list of students under 21 based on the DOB field? I googled to find a command: 


      FullAge (calculation, text result) = 
      GetAsText ( Year ( Get ( CurrentDate ) )  - Year ( Birthdate ) - If ( Get ( CurrentDate ) <  Date ( Month ( Birthdate ) ; Day ( Birthdate ) ; Year ( Get ( CurrentDate ) ) ) ; 1 ; 0 ) ) & " Years, " & GetAsText ( Mod ( Month ( Get ( CurrentDate ) ) - Month ( Birthdate ) + 12 - If ( Day ( Get ( CurrentDate ) ) < Day ( Birthdate ) ; 1 ; 0 ) ; 12 ) ) & " Months, " & GetAsText ( Day ( Get ( CurrentDate ) ) - Day ( Birthdate )  + If ( Day ( Get ( CurrentDate ) )  ≥ Day ( Birthdate ); 0 ; If ( Day ( Get ( CurrentDate ) - Day ( Get ( CurrentDate ) ) ) < Day ( Birthdate ) ; Day ( Birthdate ) ; Day ( Get ( CurrentDate ) - Day ( Get ( CurrentDate ) ) ) ) ) ) & " Days " 

      I don't exactly understand if this command will work since my category of birthdates is called DOB.  Would replacing "Birthdate" with "DOB" make this command work? 

      Also- I am not sure even how to implement the code. Do I create a button? What do I do to complete this task?

            

      I would appreciate all the help I can get.

      Thank you

        • 1. Re: Need to generate list of Under 21 from DOB category
          philmodjunk

               This calculation is needlessly complex if you just need to know the person's current age in years.

               Let (  [ B = DOB ;
                           T = Get ( CurrentDate )  
                        ] ;
                           Year ( T ) - Year ( B ) - ( T < Date ( Month ( B ) ; Day ( B ) ; Year ( T ) ) )
                     )

               As long as this is an unstored calculation and DOB is a field of type date, not text, this will give you the person's age in years. This should be an unstored calculation field in order to make sure that the value returned will update automatically with the passage of time.

               With this as a calculation field that specifies a Number result type, you can enter find mode and specify <21 in this calculation field to perform a find for all records where the age is less than 21.

          • 2. Re: Need to generate list of Under 21 from DOB category
            MaryMurray

                 Awesome. Now how would I create this ? Where do I put in the calculation you've given me?

            • 3. Re: Need to generate list of Under 21 from DOB category
              philmodjunk

                   You would go to Manage | Database | fields and create a new field of type calculation and enter this calculation as the expression for that field. You'd then select "Number" from the result type drop down and click the storage options button to select "do not store..." as the storage option for it.