AddMonths
Properly adds months to dates
Average rating: 5.0 (2 votes) Log in to vote
Ian Summerfield - Show more from this author |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
You don't need this function! Please don't tell me you can simply add to the month using the date function! You can't. If you are working with Payrolls or something similar, you need this function.
I wanted to pay someone on the 30th of each month, but there is no 30 in February. Filemaker handles this by simply wrapping over in the next month, resulting in the 2nd March. Any normal company will pay on the last day on the month instead. This function deals with it, it'll return 28th Feb or 29th Feb as needed by simply seeing the day no longer matches after adding the required amounts of months and then reverting to 1st of that month and deducting a day, that gives the last day of the month, Jan 30 + 1 month = Mar 03; make that Mar 01 and deduct a day; result = Feb 28 or 29.
Comments
Bruno Pelletier, Geniewave Mar 3, 2021 |
||
Thanks Ian, very useful function ! | ||
Greg Hains, Divide By Zero Pty Ltd Mar 16, 2023 |
||
Despite it's simplicity, this really is very useful. Thankyou Ian. | ||
Craig List Apr 23, 2024 |
||
Extremely useful! Critical for calculating expiration dates for patents. | ||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.