@Chr1sG for complete context, I’m trying to automate the creation of a new entity that’s populated with a date that is a month after the previous entity. However the date needs to be set to specific day of the week each month, like “the first Monday” or “the third Wednesday”, not the exact day number. I was thinking week number in a month was important, but maybe there’s a better way?
Basically, on the 1st of every month, if a service.state = active and service.frequency = monthly, create a new “appointment” entity linked to that service and set appointment.date to the service.appointment.sort(date).last.date’s day of the week and occurrence position.
So if service.appointment.sort(date).last.date = Jan 22, 2025, which is the 4th Wednesday of that month, the new appointment’s date would be set to Feb 26, 2025. And for the next appointment after that it would be Mar 26, 2025, then April 23, 2025, etc, etc.
If DateField is Jan 22 2025, then the result will be Feb 26 2025.
If DateField is Feb 26 2025, then the result will be Mar 26 2025.
And so on.
The only problem is that it breaks down if the following month does not have enough days of the day-of-the-week in question. For example, January 29 2025 is the 5th Wednesday in the month, but there aren’t 5 Wednesdays in February, so there is no correct answer (and the formula in this case will roll over to the next month).
It doesn’t answer your original request, but I hope it addresses the underlying need.