 # Number of a weekday in a month ( DateOfMonth ; DayWeek )

This CF calculates the number of a week day in a given month     Average rating: 4.5 (25 votes) Log in to vote Raul Basurco Sistemas Expertos Peru http://www.sistemas-expertos.pe
Sample input:
Number of a weekday in a month ( 9/1/12 ; "Sundays" )
Sample output:
5

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

Number of a weekday in a month ( 9/1/12 ; "Sundays" ) = 5
This means September 2012 has 5 sundays

This CF could be useful to calculate work days, holidays, etc.
Works in English and Spanish (as I live in Peru).

This CF has been partially translated to English and should work. Nicole, NYApr 17, 2013 Part of the custom function is labeled wrong and unless you know Spanish you wont be able to know how to fix it. Currently if your parameter is set to DayWeek like listed above it you will get an error when making the custom functiom. Where it says "dia de la semana" should actually be labeled as DayWeek Nicole, NYApr 17, 2013 Doesnt seem to work for year 2013 Perhaps this needs to be changed? Just dont know to what :P Nº de días del mes = Abs ( ( Fecha - ( Date ( Month ( Fecha ) + 1 ; 1 ; Year ( Fecha ) ) - 1 ) ) - 1 ) ; dougfan, NYCMay 13, 2015 This calc is a mess; not sure it's even correct as-is, but I cleaned it up here... If ( DateOfMonth = GetAsDate ( DateOfMonth ) and PatternCount ( "Sunday¶Monday¶Tuesday¶Wednesday¶Thursday¶Friday¶Saturday" ; DayWeek ) = 1 ; Let ( [ dte = Date ( Month ( DateOfMonth ) ; 1 ; Year ( DateOfMonth ) ) ; mno = Abs ( ( dte - ( Date ( Month ( dte ) + 1 ; 1 ; Year ( dte ) ) - 1 ) ) - 1 ) ; dno = DayOfWeek ( dte ) ; sun = If ( dno = 1 and mno ≥ 29 ; 5 ; If ( dno = 7 and mno ≥ 30 ; 5 ; If ( dno = 6 and mno = 31 ; 5 ; 4 ) ) ) ; mon = If ( dno = 2 and mno ≥ 29 ; 5 ; If ( dno = 1 and mno ≥ 30 ; 5 ; If ( dno = 7 and mno = 31 ; 5 ; 4 ) ) ) ; tue = If ( dno = 3 and mno ≥ 29 ; 5 ; If ( dno = 2 and mno ≥ 30 ; 5 ; If ( dno = 1 and mno = 31 ; 5 ; 4 ) ) ) ; wed = If ( dno = 4 and mno ≥ 29 ; 5 ; If ( dno = 3 and mno ≥ 30 ; 5 ; If ( dno = 2 and mno = 31 ; 5 ; 4 ) ) ) ; thu = If ( dno = 5 and mno ≥ 29 ; 5 ; If ( dno = 4 and mno ≥ 30 ; 5 ; If ( dno = 3 and mno = 31 ; 5 ; 4 ) ) ) ; fri = If ( dno = 6 and mno ≥ 29 ; 5 ; If ( dno = 5 and mno ≥ 30 ; 5 ; If ( dno = 4 and mno = 31 ; 5 ; 4 ) ) ) ; sat = If ( dno = 7 and mno ≥ 29 ; 5 ; If ( dno = 6 and mno ≥ 30 ; 5 ; If ( dno = 5 and mno = 31 ; 5 ; 4 ) ) ) ] ; [cont...] dougfan, NYCMay 13, 2015 ...here's the last bit... Case ( DayWeek = "Sunday" ; sun ; DayWeek = "Monday" ; mon ; DayWeek = "Tuesday" ; tue ; DayWeek = "Wednesday" ; wed ; DayWeek = "Thursday" ; thu ; DayWeek = "Friday" ; fri ; DayWeek = "Saturday" ; sat ; "Error" ) ) ; "Error" )