The following code returns the dayofweek of /weeks/ ago dayofweek: 1 weeks: 2 date: either now/weekday = dayofweek [now - (7 * (weeks - 1))] [now - (((7 * (weeks - 1)) - dayofweek) + now/weekday)]
GiuseppeC
Note that this formula is dangerous when you want to filter something from a start to and date because it includes TIME! now should be changed to now/date
DideC
I have a generic calculation for dates: date-of-monday: a-date + 1 - a-date/weekday If you need a sunday, it become: date-of-sunday: a-date + 7 - a-date/weekday Then just add or remove (weeks * 7)
GiuseppeC
Interesting
Arnold
What should same-day-next-month be today?
Gregg
That would be open to interpretation on a day like today. My call, when I wrote that func, was to use the last day of the month, if the next month has less days than the target month.
Alternately, you could throw an error or return none.