3 Replies Latest reply on Aug 10, 2011 3:18 PM by raybaudi

    Dates

    David_DMD

      Title

      Dates

      Post

       I'm needing to add one year to a date in a date field then put the result into another field. I want to automate the task so as you enter todays date it adds one year to it then enters that sum in another field. If today is 08/10/2011  plus one year; the result is 08/10/2012. How do you add dates? I using FMP ver 11 advanced.

       

      Thanks in advance,

      David

        • 1. Re: Dates
          philmodjunk

          Use this calculation. It can be for a field of type calculation set to return date or a date field with an auto-enter calculation:

          Date ( Month ( DateField ) ; Day ( DateField ) ; Year ( DateField ) + 1 )

          • 2. Re: Dates
            ninja

             Hi David,

            If it is just today's date, insert the "Get(CurrentDate)" function below as appropriate.  I am assuming that the date entered may not be just today's date...
            I'm also assuming that your first entry field is called "DateField"

             

            Calculation field, resulting in Date, defined as:

                           GetAsDate(  Month(Datefiled) & "/" & Day(DateField) & "/" & Year (DateField) +1 )

            {I think you could do this with semicolon separators also}

             

            This would be a dynamic field, and would change if the value in "DateField" changes...is this what you want?

            • 3. Re: Dates
              raybaudi

               " If today is 08/10/2011  plus one year; the result is 08/10/2012"

              ... and what must be the result if today is 02/29/2008 ? If your answer is: 02/28/2009, try this calculation:

              Let(
              d = YourDateField ;
              Date ( Month ( d ) ; Day ( d ) - ( Month ( d ) = 2 and Day ( d ) = 29 ) ; Year ( d ) + 1 )
              )

              or, that is the same:

              Let([
              d = YourDateField ;
              leap = Month ( d ) / Day ( d ) = 2 / 29
              ];
              Date ( Month ( d ) ; Day ( d ) ; Year ( d ) + 1 ) - leap
              )