MonthNumber ( monthName )
Convert month name to a number
Average rating: 4.5 (43 votes) Log in to vote
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Returns the month number for any month name.
Ward Clark, Townsend, MA
May 15, 2010
|The function parameter name cannot be "monthName" because FileMaker 11 has a MonthName function. I changed the name to "text".|
Thomas Keller, Portland
Sep 3, 2010
|Very clever. Great use of custom functions.|
Feb 17, 2012
I wanted to be able to get the month number out of a complete date no matter where it was located (e.g. "January 1, 2012" or "08-FEB-12"), so I filtered:
Left ( Filter (text; "JjAaNnFfEeBbMmYyUuLlGgSsPpOoCcTtVvDd" ); 3 ) ;
David, Sydney, Australia
Feb 17, 2012
The CF was designed to accept either a month name or an expression that results in a month name e.g. Monthname ( dateField ). So you have modified it to accept any input that may contain a month name. Fair enough use.
This is a clever way to filter the required treat out of the string and then pass it to the function. Obviously the 'complete date' you are parsing is text not date. You have correctly used upper and lower case because the Filter function is case-sensitive. However, you have omitted "r" :)
So I would tend to be more comprehensive and filter every possible letter to ensure completeness. I would also convert to uppercase (or lower) first to avoid the need for duplication:
Filter ( Upper ( text ); "ABCDEFGHIJKLMNOPQRSTUVWXYZ" )
Anyway, a good addition to the functionality of the CF. :)
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.