1 of 1 people found this helpful
When using this kind of date offset, I tend to use something like:
Let ( [
today= Get ( CurrentDate )
; dayOfWeek= DayOfWeek ( today )
; offset= Choose ( dayOfWeek ; 0 ; -6 ; 0 ; -1 ; -2 ; -3 ; -4 ; -5) // shift to most recent Monday
; newDate = today + offset
This gives you a lot of flexibility, since you are specifying how much to shift the final date for each individual day of the week.
Don't forget that the Choose() function is ZERO indexed, so there should be EIGHT values in the calculation, one for the zeroth element, one for the first, one for the second, etc.
Hope this Helps,
I had seen something similar to this in searching on the forums here. I think I would have to make the Choose statement a bit different, since I want to go back to the previous Monday if today is Monday:
Choose (dayofWeek; 0; -6; -7; -1...
I had been trying to make the original into a one-line calc, but couldn't get my brain around the math.
I want it to show last Monday's date. If it is Tuesday or later, I want it to show this Monday's date.
Let ( d = Get ( CurrentDate ) ; d - Mod ( DayofWeek ( d ) - 3 ; 7 ) - 1 )
I knew there had to be a way to do this without using the Choose function.