and(A,B) = if(A,if(B,1,0),0) ... but I agree, if it ain't broken, don't fix it. However in this case I was trying to understand your expression and I found it so convoluted that I just decided to rewrite it.
Regarding Sunday - actually the starting day for %w is Sunday, not Monday as I said above. So the above expressions are returning Sunday-to-Saturday. To adjust for Monday-to-Sunday we need to tweak the calculation a bit, like so:
This Week, starting on Monday:
[=isEqual(left([last played,0],5), Math(left(now(),5) - (formatdate(left(now(),5),%w)+6)%7), 6)]=1
Previous Week, starting on Monday:
[=save(left(now(),5), today)/
save(left([last played,0],5), played)/
save(Math([today] - (formatdate([today],%w)+6)%7), currWeekStart)/
save(Math([currWeekStart] - 7), prevWeekStart)/
and(isEqual([played], [prevWeekStart], 6), isEqual([played], [currWeekStart], 3))]=1
Only change is in currWeekStart, see if you can figure out what's it doing
These expressions work on any week, including rollover on week 52/53-00. They just deal with the day number (today is 44058), calculate the week start day using %w (currWeekStart), and then check if [prevWeekStart] <= [Last Played] < [CurrWeekStart].
Only change is in currWeekStart, see if you can figure out what's it doing
Deary me, this made my head hurt...
get the day of week number, add 6, divide by 7, the remainder is the correct number to subtract back to Monday.
This is a really neat approach. As the weeks roll by, the 'day of week number' rotates around 0 - 6, as 'today' gets ever larger. It should always work.
It wouldn't work for me at first, until I realised that I already have library fields named [Today] and [Played] and these were being used in priority over the variable names. Once I changed the variable names all was good.
Re: week 53 into week zero...
Thursday 2nd January 2020 = 43832
formatdate(43832,%w) = 4
Meaning this will take care of the whole "week zero" question in a much more refined and direct way than my solution. I would never have arrived here on my own. Thank you very much for the lesson
-marko