Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6818 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello,

As I am trying to expand my experiance, I'm trying to make calculations harder on myself so I can learn. Here is what I did with finding the month number from a Month Name:




Let (

list =  ValueListItems ( Get ( FileName ) ; "Month List" );



ValueCount ( Left (list ; Position ( list ; Month::SelectMonth ; 1 ; 1 ) + Length ( Month::SelectMonth ) ) )



)

SelectMonth Values:

January

Febraury

March

April

May

June

July

August

September

October

November

December

I didn't want to hardcode any months even though I could have used a simple Case function; what other ways are there to calculate a month number based on its name?

Thanks and God Bless!

David

Posted

I can think of several, but when you say you don't want to hardcode, it begs the question of language. You yourself have hardcoded the ENGLISH month names into a value list. What if the user is French?

Another question is the input method: in English, the first 3 letters of the month name are enough to identify the month. So if you limit yourself to English, you could use the same formula for short or full month name as the input, for example:

Let ( [

string = "janfebmaraprmayjunjulaugsepoctnovdec" ;

mmm = Left ( Input ; 3 )

] ;

Ceiling ( Position ( string ; mmm ; 1 ; 1 ) / 3 )

)

It wouldn't be too hard to compile a list of 12 month names in the current language, but I don't know the minimum length required to identify the month in each languages.

Posted

Hi

I know the you own FM8 and not the Advanced version, but isn't to difficult to ask someone to make a black file with this custom inside...

This custom function makes what you want and is *NOT* depending from the used language.

------------------------

/*

MonthNameToMonth custom function

Author: Daniele Raybaudi

Format: MonthNameToMonth ( theMonthName ; start )

Parameters:

theMonthName - text

start - number (must be set to 1)

Returns the month number of the given monthName

*/

Let([

date = Date ( start ; 1 ; 1 );

month = Month ( date )

];

Case(

start > 12 or IsEmpty ( theMonthName ) ; "?" ;

MonthName ( date ) = theMonthName ; month ;

MonthNameToMonth ( theMonthName ; start + 1 )

)

)

Posted

for example, the attached file is for ITALIAN's and you can try it with italian monthNames:

gennaio = 1

febbraio = 2

....

For use with English monthNames, simply make a clone of the file ! :

blankFile.zip

This topic is 6818 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.