4 Replies Latest reply on Jan 3, 2017 12:48 PM by kbcomp

    Date Calculation

    kbcomp

      Can someone tell me step by step how to create a field with the current date, then  create a field with a birthdate, then create a field with a contacts age that will be calculated by subtracting the current date from the birthdate. I have tried every way I can think of, but I am not getting the correct number.

       

      Thank You.

        • 1. Re: Date Calculation
          SteveMartino

          I'm not trying to give you a hard time, but this is very very basic.

          You only need a field for birth date, formatted as Date (call it birthdayfield), and a field for age, which would be a calculation like this:

          round((get(currentdate)-Table::birthdayfield)/365;1) //formatted as a number.

           

          There are also custom functions:

          FileMaker Pro Custom Functions

          • 2. Re: Date Calculation
            erolst

            kbcomp wrote:

            I have tried every way I can think of, but I am not getting the correct number.

            Including searching this forum?

             

            Of course the 'right' answer depends on how you wish the age to be expressed.

             

            Here's a basic variant that displays the age difference in completed years (aka 'people's age'):

             

            Let ( [

              cd = Get ( CurrentDate ) ;

              dob = YourTable::birthdayDate

              ] ;

              Year ( cd ) - Year ( dob ) - ( Month ( dob ) >= Month ( cd ) and Day ( dob ) > Day ( cd ) )

            )

             

            PS: Totally forgot: you need to set the storage type to unstored (ie check the "Do not store ..." checkbox); otherwise the result will not be updated. That applies to all calculations that involve Get ( SomeThing ) functions.

            • 3. Re: Date Calculation
              kbcomp

              Thank You for the information.

              • 4. Re: Date Calculation
                kbcomp

                Thank You for the information.