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
AbAb 

Validation rule to check if date is not less than current month

Hello,

I have a CustomObject1__c

I want to put a condition where
IF the Status__c = 'XyW'
  then - CustomDateField is Mandatory && Date cannot be less than current month

Date can not be less than current month means
If today is 25 october2019  the date can be greater thatn 1st October 2019

Thank you for suggestion
          
Best Answer chosen by Ab
Deepali KulshresthaDeepali Kulshrestha
Hi Sandrine,

I have gone through your question. The validation rule on the date should not less than the current Month.
Please follow the below to achieve this:-

Validation--->

if((Status__c == 'XYZ') && Month(Date__c) < Month(today()), true,false)


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
www.kdeepali.com
 

All Answers

vamsi lankisettyvamsi lankisetty
Hi Sandrine,

We can create this through Validation Rule

As per your question what i understood is

If status ( picklist ) = 'xyz'
Then the custome Date field should be in the same month as you said it should be in October.

Create the validation rule in your custom object and paste this code in this

IF(ISPICKVAL( Status__c , 'B'), Month (Today()) !=  MONTH( Custom_Date_Field__c ), true)

User-added image

Here i have taken Fields Status__C and my pick list value is B. You can change it according to yours.

If you are happy with the answer, please keep it as sloved.. :)

 
Deepali KulshresthaDeepali Kulshrestha
Hi Sandrine,

I have gone through your question. The validation rule on the date should not less than the current Month.
Please follow the below to achieve this:-

Validation--->

if((Status__c == 'XYZ') && Month(Date__c) < Month(today()), true,false)


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
www.kdeepali.com
 
This was selected as the best answer
Ajay K DubediAjay K Dubedi
Hi Sandrine,

I have gone through your question. I have created a validation rule for your scenario.
Here is my validation rule - 

Status__c = 'XyW'  && ( ISBLANK(Custom_Date__c) || ( MONTH(Custom_Date__c )  <  MONTH( TODAY() ) ) )


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

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
AbAb
Hello All,

With abouve all solution, if i put the year less than current year and month higher than current month, it fails
Frank RoyallFrank Royall

"Here is my validation rule - 

Status__c = 'XyW'  && ( ISBLANK(Custom_Date__c) || ( MONTH(Custom_Date__c ) (Link: https://casinohex.at/online-casinos/neue/) <  MONTH( TODAY() ) ) )"

Thank you Ajay, I've tested already your code - it's really working,thank you