Brian Dunning's FileMaker Custom Functions

MonthNumber ( monthName )

Convert month name to a number

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

David Head   David Head - Show more from this author
uLearnIT
http://www.ulearnit.com.au/

Share on Facebook Share on Twitter

  Sample input:
MonthNumber ( "September" )
  Sample output:
9

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

Returns the month number for any month name.

 

Comments

Ward Clark   Ward Clark, Dancing Bears
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   Thomas Keller, Portland
Sep 3, 2010
Very clever. Great use of custom functions.
 
Eric   Eric, SJSU
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:

Position
(
"xxJanFebMarAprMayJunJulAugSepOctNovDec" ;
Left ( Filter (text; "JjAaNnFfEeBbMmYyUuLlGgSsPpOoCcTtVvDd" ); 3 ) ;
1 ;
1
)
/3
 
David   David, Sydney, Australia
Feb 17, 2012
Hi Eric
Good feedback.

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. :)
Cheers, David
 
Brad Cassity   Brad Cassity
Dec 17, 2018
Thanks David! Good work.
 

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 15 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:

Under construction. Email me your wish list for improvements.