cancel
Showing results for 
Search instead for 
Did you mean: 

Count Sundays in Current Month

0 Kudos

Hi All,

Looking for a way to count the number of Sundays in the current month via a variable?

e.g. Today = 30/11/2020, Days in month = 30 & Sundays in month = 5

Thanks for any help.

Accepted Solutions (0)

Answers (1)

Answers (1)

ayman_salem
Active Contributor
0 Kudos

Define the following variables:

exDate: =ToDate("13.10.2020"; "dd.MM.yyyy")

Note: This an example date, and you can put other date or use CurrentDate()

lastDayOfMonth: =LastDayOfMonth([exDate])

DayNrOfWeek_LastDayOfMonth: =DayNumberOfWeek([lastDayOfMonth])

DateOfLastSundayOfMonth: =If ([DayNrOfWeek_LastDayOfMonth] = 7) Then [lastDayOfMonth] Else RelativeDate([lastDayOfMonth]; -[DayNrOfWeek_LastDayOfMonth])

DayOfMonthLastSunday: =DayNumberOfMonth([DateOfLastSundayOfMonth])

NoOfSunday: =Ceil(([DayOfMonthLastSunday]) / 7)

...

Result example for different months:

...

Hope this gives you an idea of how to meet the requirements