Restrict specific day selection

Ooh, this is a fun one :tada:. @A.N.M_AL-IMRAN is right that you could hard code the test for every individual Friday and Saturday but that sounds pretty tedious. Another approach is to use decimal-date-time which provides the number of days since January 1, 1970 UTC.

Your constraint would look something like:

int(decimal-date-time(.)) mod 7 != 1 
  and int(decimal-date-time(.)) mod 7 != 2

mod 7 uses my favorite operator, the modulus operator to identify which of the 7 days this is. Jan 1, 1970 was a Thursday so Friday has an index of 1 and Saturday has an index of 2.

I don't think there needs to be any timezone adjustment thought it's possible there does. I'm also not sure the int() calls are needed but they shouldn't hurt. @ARIF_AZAD_KHAN could you give that a try and report your findings?

6 Likes