Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
Coral Racing

# Validation Rule Help with a DATE / Time

Hello,

I have a date time field that users manually select for when they want to implement a Change but I want to limit their selections to only Monday, Wednesdays and Fridays of each week.

Can anyone help?
Many Thanks

Sonya
vibhor goel
Hi Sonya,

I am not sure if you are looking for the full logic of the validation Rule or just the way to get the Day of the week in validation.

In case you are trying to find a way to get the days then,
https://help.salesforce.com/HTViewHelpDoc?id=formula_examples_dates.htm&language=en_US#getting-dmy-from-date

Here under the section - 'Finding and Displaying the Day of the Week From a Date' you can find a way to do so.

Hope it helps!!

Regards,
Vibhor

Coral Racing
Hi Thanks, I did see this before, but what I am looking for is a validation rule that throws an error if the User selects a date that does not fall on a Monday , Wednesday or Friday. Thanks Sonya
Hi,

Please find the below validation rule,

NOT(OR(MOD( TestDate__c - DATE(1900, 2, 3), 7) = 2, MOD( TestDate__c - DATE(1900, 2, 3), 7) = 4, MOD(TestDate__c - DATE(1900, 2, 3), 7) = 6))

Replace TestDate__c  with your date field.

Thanks,
Vinoth
Coral Racing
Thanks both, really quick responses.  I will try both methods

Much apprciated
Hi,

I have made few changes for Date Time field. Please find the below formula.

NOT(OR(MOD(  DATEVALUE(TestDate__c)  - DATE(1900, 2, 3), 7) = 2, MOD( DATEVALUE(TestDate__c) - DATE(1900, 2, 3), 7) = 4, MOD( DATEVALUE(TestDate__c) - DATE(1900, 2, 3), 7) = 6))

Thanks,
Vinoth
Coral Racing
Thanks for this. I tested the conditional formula and I am getting the following error Insert Operator Error: Incorrect argument type for function 'DATEVALUE()'.
Coral Racing
Apologies, it would appear my field is Date and not Date/Time so the formula below does not work as not a datetime value

NOT(OR(MOD(  DATEVALUE(TestDate__c)  - DATE(1900, 2, 3), 7) = 2, MOD( DATEVALUE(TestDate__c) - DATE(1900, 2, 3), 7) = 4, MOD( DATEVALUE(TestDate__c) - DATE(1900, 2, 3), 7) = 6))
Coral Racing
I changed it to this

NOT(
OR
(MOD((CAB_Date__c) - DATE(1900, 2, 3), 7) = 2,
MOD((CAB_Date__c) - DATE(1900, 2, 3), 7) = 4,
MOD((CAB_Date__c) - DATE(1900, 2, 3), 7) = 6)
)