These give the week number 0 to 4 within the month of Date and of Date + 28 days.
You can now calculate your next date using
Date+if(WD=WD28,28,35)
That is you add 4 weeks to Date if the date 28 later has the same week-in-month value, or add 5 werks otherwise.
I tried to create the calculation without using the additional fields but this seemed to be too complicated for the Sailforms equation editor - it would not allow me to put brackets where I needed them.
Do you also need to be able to calculate the first date? If so, what information is available to this calculation?
Mike
Perhaps you have already attempted something like this but first Friday is relatively easy compared to some more difficult 'picks'.
We know:
First Friday is some where between the 1st and the 7th of each month.
Sailforms 'weekday' is a command/function reporting what day of the week a particular date 'occupies'. (Friday = 6)
Sailforms 'todate' is a command/function that builds a date from year, month, and day. This and perhaps other commands has a play in your effort.
Sailforms 'if' command stacked into case series can help you find Friday (6).
I read your request for help just a few minutes ago. Building your solution may be easier broken down into several fields perhaps stored in a form that is feed a request and returns a date. This is all thinking without touching Sailforms.
Your request is a good one. I bet MikeG is working on the puzzle solution as I type this note. If not, I hope these ideas help you build your own.
Doug
Appreciate your help.
If you want a numeric value for day of week use Date%7 (where Date is your date field). This gives a value 0 to 6 (0 = Monday, ..., 6 = Sunday).
Mike
One can obtain the date of the 3rd Friday of September, 2020.
It could be used as a 'called form' that returns the found date for your specifications. This may help implementation because establishing the various hidden fields and the equations in your form is a fairly heavy job.
I suspect MikeG. will find a simpler solution but I found taking incremental steps with smaller equations easier for me. Doing that created several hidden fields.
If one was inclined to do a re-build, I'd recommend making the hidden fields unsaved. In addition, I used 2 methods to swap between day name and day number. That too, could be cleaned up.
Lastly, GiveMeDate uses 2 form layouts. This is becoming a 'best practice' for me. The default layout FindTheDate is for run time and SupportingFields layout is for development work and debugging. This is easier than toggling hidden fields on and off.
Doug
I hope you enjoyed working the puzzle as much as I did. It made me turn off TV to focus. No, my comment was not intended to be a challenge. Instead, it was intended as a complement about your skill with Sailforms. Your reaction made me smile!
I don't see a big difference between the solutions on a complexity score. I DO see you used the more recent tools added to Sailforms. That means I need to open my eyes and play with them. Tools left un-used can't serve me.
Doug
Note:
My solution was going to include a "Last in month" option (which effectively means 5th if there is one, else 4th) bit I forgot about it so it doesn't work!
Mike