function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
S b 25S b 25 

need to exclude weekends using validation rule

Hi, I want to exclude validation rule to fire when users enter any weekend date for a date field.

Any suggestions would help. 

Thanks in advance.
Best Answer chosen by S b 25
Steven NsubugaSteven Nsubuga
Try this. Assuming that Date__c is the field 

OR(MOD(Date__c - DATE( 1900, 1, 7 ), 7 ) == 0, MOD(Date__c - DATE( 1900, 1, 7 ), 7 ) == 6)

All Answers

Steven NsubugaSteven Nsubuga
Try this. Assuming that Date__c is the field 

OR(MOD(Date__c - DATE( 1900, 1, 7 ), 7 ) == 0, MOD(Date__c - DATE( 1900, 1, 7 ), 7 ) == 6)
This was selected as the best answer
S b 25S b 25
@steven, It works perfectly fine, thanks :)
S b 25S b 25
Hello @Steven

I have one small query, can you let me know what 1900 means in the validation rule ?

Thanks
Steven NsubugaSteven Nsubuga
It represents a date in the past, DATE( 1900, 1, 7 ) is the date 1 January 1900. Usually such dates are picked to make it easy to calculate other dates. 
James Hill 34James Hill 34
Hi @steven

I'm creating a rule on the task object to require the due date is a weekday and require that the date selected is atleast 5 days out. Trying to use your logic into what I already have and found no syntax errors. In testing I'm able to save the task just fine but am still able to select days on the weekend. Can you please tell me where there's an error and what edit needs to be made to this logic?

AND(

RecordType.Name = "Premier Success" , ActivityDate <= TODAY()+5,

OR(MOD( ActivityDate - DATE( 1900, 1, 7 ), 7 ) == 0), MOD( ActivityDate - DATE( 1900, 1, 7 ), 7 ) == 6
)

Thanks for your help