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
Girbson Bijou 8Girbson Bijou 8 

Specific date in Validation rule

I need to implement a validation rule which should take effect  for all new record created after a specific date. I have a field called  Unit_Cost__c , this field can not be blank for all records created after  July 25, 2019. Below is a draft of my work.  The error message is: Syntax error. Missing ')'

AND(DateValue(CreatedDate)=>Date(2019, 07,25 ), 
(ISBLANK(  Unit_Cost__c  )))
Best Answer chosen by Girbson Bijou 8
Deepali KulshresthaDeepali Kulshrestha
Hi Girbson,

The formula is correct but there a small change that needs to be done.
Here the operator sign should be like >= and that is the format of Salesforce. Please update your formula for the validation rule:

AND(DateValue(CreatedDate)  >=   Date(2019, 07,25 ), 
ISBLANK( Unit_Cost__c ))

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha 

All Answers

Deepali KulshresthaDeepali Kulshrestha
Hi Girbson,

The formula is correct but there a small change that needs to be done.
Here the operator sign should be like >= and that is the format of Salesforce. Please update your formula for the validation rule:

AND(DateValue(CreatedDate)  >=   Date(2019, 07,25 ), 
ISBLANK( Unit_Cost__c ))

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha 
This was selected as the best answer
Girbson Bijou 8Girbson Bijou 8
Hi Kulshrestha, 
Thank your for replying so quickly. your solution works but something is strange for me. This validation rule work only when i am updating a record but it does not prevent me to create a new record with Unit_Cost__c blank. 

Thanks for yoyur additional help.

Best,
Deepali KulshresthaDeepali Kulshrestha
Hi Girbson, 

The validation rule will prevent to the save the record while updating it only and will not work while creating a new one as the field you're using in it that is Created date will not be available at the time of creation. It will be there after the creation and when the record will get updated, it can fetch the value of the Created Date field and prevent to save it if the rule matches the condition.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
Jared RoachJared Roach
When creating a record you can use now() in the place of createddate so....

AND(DateValue(Now())  >=   Date(2019, 07,25 ), 
ISBLANK( Unit_Cost__c ))