Brian Dunning's FileMaker Custom Functions

WeekOfMonth ( _date ; startingDay )

Returns a number between 1 and 6 representing the week containing date

  Average rating: 4.2 (40 votes) Log in to vote

Daniele Raybaudi   Daniele Raybaudi - Show more from this author
ACI
http://www.aci.it

Share on Facebook Share on Twitter

  Sample input:
WeekOfMonth ( "06/07/2009" ; 1 )

WeekOfMonth ( "06/07/2009" ; 2 )
  Sample output:
2

1

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

WeekOfMonth ( _date ; startingDay ) custom function ( not recursive)

Author:
Daniele Raybaudi

Parameters:
_date - any calendar date
startingDay - any number between 1 and 7, where 1 represents Sunday

Data type returned:
number

Description:
Returns a number between 1 and 6 representing the week containing date, figured according to startingDay. startingDay indicates which day is considered the first day of the week.

 

Comments

Robert D Trammel   Robert D Trammel, Lucky Penny LLC
Nov 3, 2023
Thanks for this function. I modified it a bit so that it only needs to take the date.
/*Data type returned:
number

Description:
Returns a number between 1 and 6 representing the week containing date, figured according to startingDay. startingDay indicates which day is considered the first day of the week.
*/

Let([
startingDay = DayOfWeek( Date( Month( _date ); 1; Year( _date ) ) );
first = Date ( Month ( _date ) ; 1 ; Year ( _date ) )
];
WeekOfYear ( _date ) - WeekOfYear ( first ) + 1 - ( DayOfWeek ( _date ) = startingDay - 1 ) + ( DayOfWeek ( first ) = startingDay - 1 )
)
 

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: