Brian Dunning's FileMaker Custom Functions

lastMonth ( theDate )

Give you the last month in number

  Average rating: 4.5 (18 votes) Log in to vote

Jo Des Rosiers   Jo Des Rosiers
Company
http://google.com

Share on Facebook Share on Twitter

  Sample input:
lastMonth ( "" )
lastMonth(Date (1;20;2015))
lastMonth(Date (10;7;2015))
  Sample output:
depend on the current date
12
9

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Give you the last month in number. If the date is an empty string it will depend on the current date.

 

Comments

unix   unix, Japan
Mar 1, 2016
Let ( cd = Get ( CurrentDate ) ;
Month ( cd - date( cd ) )
)

Using Let() save change of current data in calculating.
 
Bernamo   Bernamo, Belgium
Mar 2, 2016
Hello unix,
I presume "date( cd )" must be "month( cd )" ?
Best regards.
 
Jo   Jo, Switzerland
Mar 3, 2016
I edited the function to take a date in parameter. If you give and empty string it will work like the last version.
 
unix   unix, Japan
Mar 3, 2016
Thanks Bernamo,
It should be Day( cd ).
(And "current data" should be "current date", of course)

aDate - Day ( aDate )
returns the last date of previous month.

I frequently confuse date and day...
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: