4 Replies Latest reply on Oct 19, 2015 2:59 PM by stephensexton

How can I add 1-12 months to a date not days. eg. 09/02/1025 + 1 month = 10/02/2015

• ###### 1. Re: Date adding

Hi.

You can add to the specific month. I think I'd do it this way.

Let ([

_Start = Date (9;2;2015);

];

Date ( Month (_Start) + _AddTo ; Day (_Start) ; Year (_Start) )

)

Here I'm taking the month in the _Start variable and adding to it the number of months in the _AddTo variable. (Of course the addend can be a field).

If you have FileMaker Pro Advanced, you could even create a custom function called: MonthAdd (GivenDate ; MonthsToAdd):

Let ([

_Start =GivenDate;

];

Date ( Month (_Start) + _AddTo ; Day (_Start) ; Year (_Start) )

)

--------

Creating that will allow you to simply call this function and pass in the date you want and the number of months you want to add it to.

• ###### 2. Re: Date adding

Hi Mark,

Try:     Date ( Month ( field ) + 1 ; Day ( field ) ; Year ( field ) )

Where "field" equals your starting point.

• ###### 3. Re: Date adding

Date2 =

Date (

Month(Date1) + 1 ;

Day(Date1) ;

Year(Date1)

)

... but you would need to account for issues that occur when the next month has less days than the previous month... e.g. adding 1 month to Jan 30th will bring up March 1st.

One way of dealing with that would be to use a Let statement to calculate a series of variables (starting with the above calculation) and check if the resulting day number is the same between Date1 and Date2 - if this is not the case, make the day number equal to the 1st of the month in Date2 minus 1.

• ###### 4. Re: Date adding

further to the last example calc, the following would work if you want to show the last day of the month when adding one month to Jan 31 st etc...

Let ([

\$a = Date1 ;

\$b = Date ( Month(Date1) + 1 ; Day(Date1) ; Year(Date1) )

];

If ( Day(\$a) ≠ Day(\$b) ; Date ( Month(\$b) ; 1 ; Year(\$b) ) - 1 ; \$b )

)