You can use parseInteger(formatDateTime($date, 'u')) to get day of the week (as a number) from a Date and time attribute so it can be used to compare to a value.
loop between two dates and check the day is equals 5.
I hope it will be helpful for you.
Given month x, how many days y does it contain? It is always a challenge to create a program that solves this kind of questions. Very rewarding once you have succeeded. But it is always more complex than expected at first, the solution is often hard to read and understand and edge-case hide in corners where you don’t expect them and it should therefor be unittested thoroughly.
To the solution, untested, just jotting down the steps:
- yourday is an integer from 1 to 7
- get the first day (type date) of the month. Include a variable ‘year’ to take leap-years into account; parseDateTime($Year, $Month, 1)
- get the last day (type date) of the month: parseDateTime($Year, $Month+1, 1) unless month =12 then: parseDateTime($Year+1, 1, 1). Wrap that answer in addDays($FirstOfNextMonth, -1)
- get the number of days in the month by daysBetween(firstday, lastday)
- if this number is:
Test it to the bone and certainly for every edgecase:
- feb 28th , feb 29th , mar1st for 2022, 2023, 2024, 2028, 2032
- dec 31st , jan 1st for 2022, 2023, 2024, 2028, 2032
Good luck and have fun.
You can get count no of particular day in a month by using
“ XPath Weekday-from-DateTime “
weekday-from-dateTime() function extracts the day of the week (as a number) from a Date and time attribute so it can be used to compare to a value. For running locally and deployment using a PostgreSQL database, such as that used in the Mendix Cloud, the values range from 1 to 7 (1 = Sunday, 7 = Saturday).
This query returns all the logs where the day of the week in
DateAttribute is 6 (Friday, for locally run apps or apps using a PostgreSQL database):
//Logging.Log[weekday-from-dateTime(DateAttribute) = 6]