Validation rule formula for Dates AFTER another date - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Lily Callaghan SmithLily Callaghan Smith 

Validation rule formula for Dates AFTER another date

Hi there

I need to edit an existing validation rule I've got, to make sure it only fires on opportunities with a Launch Date after August this year. Can someone help me with this as im not sure which Operator to use?

The field is called Requested_Launch_Date__c 
I'd want it to only be on Opportunities with Requested Launch Date after 1st August

Thank you 


For record, below is the existing formula which I will need to add it into:
AND(
ISPICKVAL(StageName, "Live"),  
OR(
ISPICKVAL(AM_Approval_Status__c , "Pending"),
ISPICKVAL(AM_Approval_Status__c , "Rejected"),
ISPICKVAL(AM_Approval_Status__c , "--None--"),
ISBLANK(TEXT(AM_Approval_Status__c ))
)
)
Best Answer chosen by Jayson (salesforce.com) 
Vivek HVivek H
Okay, if its a date field you may have to include if else in your Validation Rule formula as below:

IF(AND(DAY( Requested_Launch_Date__c )>=1,MONTH( Requested_Launch_Date__c )>=8,YEAR( Requested_Launch_Date__c  )>=2020) , AND(
ISPICKVAL(StageName, "Live"),  
OR(
ISPICKVAL(AM_Approval_Status__c , "Pending"),
ISPICKVAL(AM_Approval_Status__c , "Rejected"),
ISPICKVAL(AM_Approval_Status__c , "--None--"),
ISBLANK(TEXT(AM_Approval_Status__c ))
)
), false)

Above criteria will check if the requested launch date is greater/equal 1 August,2020.
  1. If yes then it will check your criteria & if it meets then there will be an error message else no error message
  2. If No, then it will consider false value & do not throw error message.
Hope this helps! Let me know if you have any questions.

Thanks,

Vivek H

All Answers

Vivek HVivek H

Hi Lily,

Can you help understand what is the datatype of Requested_Launch_Date__c field. Is it Date or DateTime field ?
 

Lily Callaghan SmithLily Callaghan Smith
Hi Vivek, it is a Date field. 

Thanks!
Vivek HVivek H
Okay, if its a date field you may have to include if else in your Validation Rule formula as below:

IF(AND(DAY( Requested_Launch_Date__c )>=1,MONTH( Requested_Launch_Date__c )>=8,YEAR( Requested_Launch_Date__c  )>=2020) , AND(
ISPICKVAL(StageName, "Live"),  
OR(
ISPICKVAL(AM_Approval_Status__c , "Pending"),
ISPICKVAL(AM_Approval_Status__c , "Rejected"),
ISPICKVAL(AM_Approval_Status__c , "--None--"),
ISBLANK(TEXT(AM_Approval_Status__c ))
)
), false)

Above criteria will check if the requested launch date is greater/equal 1 August,2020.
  1. If yes then it will check your criteria & if it meets then there will be an error message else no error message
  2. If No, then it will consider false value & do not throw error message.
Hope this helps! Let me know if you have any questions.

Thanks,

Vivek H
This was selected as the best answer
Lily Callaghan SmithLily Callaghan Smith
Great Vivek - thank you for your help
Vivek HVivek H

No Problem Lily, please select the above comment as best answer if it helped you, I hope it did. Happy Salesforce :)

Thanks,

Vivek H