Restrict specific day selection

Dear all,

I want to restrict users to select "Friday" and "Saturday" on the calendar. So that users can get a message do not make a plan on the weekend. Is there any way to put a constraint in the XLS?

Thanks,
Arif

Hi Arif,

Not sure about if there is any other way but for now, I would say if the length of your project is one year, restrict all weekends by using constraint. However, that going to be a big bunch of constraint though.

Thanks,
Imran

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?

5 Likes

@LN

int(decimal-date-time(.)) mod 7 != 0 restrict to select "Friday"

and

int(decimal-date-time(.)) mod 7 != 1 restrict to select "Saturday"

Many many thanks for your reply. I never thought it is possible by just putting a constraint only.

Thanks,
Arif

3 Likes

@A.N.M_AL-IMRAN thanks for your thought.