Use nearest day to a date

I have an app with repeating jobs that are scheduled for field users. There are repeating jobs that happen on variable frequency like monthly or quarterly.

Adding current day + 1 month or current day + 3 months is easy and that’s up and running.

But, I’d like to add a new feature. I’d like the user to be able to choose a preferred day of the week. So if this month’s job is on a Monday and would like the app the automatically schedule the next job to the nearest day.

So, a job carried out on 1st March 2022 is a Monday.
+3 month is 1st June 2022 which is a Wednesday
I’d like the app to adjust the scheduled day to the nearest Monday which is 30th May 2022.

Help! my brain is melting with this one!

Off the top of my head…

Something like … work out the # of days between job being done and _3 months.

Divide by 7 and … round the integer.

Maybe !

This topic was automatically closed after 70 days. New replies are no longer allowed.