Count thursdays in last month

I was looking for a way to have Shortcuts peek into last month’s calendar and count how many Thursdays were that month (4 or 5).

Any ideas on how to make it?

Try this.

https://www.icloud.com/shortcuts/6d37a63095c64317bea6ed91a41ab066

1 Like

Worked great, many thanks!

suggestion: If [Days in month] > 28 … repeat

Also, f you wanted to be smarter you could also simply just check for the first day of the month, the total days, and then return either 4 or 5. If the first is Friday-Monday, then you can’t have 5 Thursdays. If the first is Tuesday, then you can only have 5 Thursdays if it’s a 31 day month.

1 Like

I did consider constructing a dictionary (with arrays) based on the month length and the start day to utilise a lookup instead of an on the fly calculation. But it was just quicker for me to create a loop and the overhead on processing was mininal.

If I needed a high performance way of doing this I would opt for the dictionary approach,

1 Like