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
Robert EssenRobert Essen 

validation rule on experation_date__c

Hi, i'm a complete newby,

i've been asked to create a validation rule on a Date/Time field. experation_date__c, can be set to a maximum of 3 months from now.

It keeps on giving me an error: Error: Incorrect parameter type for operator '-'. Expected Number, DateTime, received Date

any advise please. Thanks

Best Answer chosen by Robert Essen
CharuDuttCharuDutt
Hii Robert
Please Don't Forget To Mark It As Best Answer If It Helps
Thank You!
IF(AND(Value(TEXT((YEAR(DATEVALUE(experation_date__c))*12+MONTH(DATEVALUE(experation_date__c)))-
(YEAR( TODAY() )*12+MONTH( TODAY())))) > 3,OR(ISPICKVAL(Status,'Draft'),ISPICKVAL(Status,'Review'))),true,false)
Please Don't Forget To Mark It As Best Answer If It Helps
Thank You!

All Answers

CharuDuttCharuDutt
Hii Robbert
Try Below Validation
IF(Value(TEXT((YEAR( experation_date__c)*12+MONTH(experation_date__c))-
(YEAR( TODAY() )*12+MONTH( TODAY())))) > 3,true,false)
Please Mark It As Best Answer If It Helps
Thank You!
Robert EssenRobert Essen

Hi Charu, 

Thanks you very much for you quick advise. I still have the same error:User-added image
 

CharuDuttCharuDutt
Hii Robert
Try Below Validation I've Changed It 
IF(Value(TEXT((YEAR(DATEVALUE(experation_date__c))*12+MONTH(DATEVALUE(experation_date__c)))-
(YEAR( TODAY() )*12+MONTH( TODAY())))) > 3,true,false)
Please Mark It As Best Answer If It Helps
Thank You!
Robert EssenRobert Essen

WoW Awesome, this is already good, unfortunately i forgot to mention one requirement. 

This actualy only applies for records in 'Status' --> 'Draft', 'Review'.

Sorry for inconvenience caused.

CharuDuttCharuDutt
Hii Robert
Please Don't Forget To Mark It As Best Answer If It Helps
Thank You!
IF(AND(Value(TEXT((YEAR(DATEVALUE(experation_date__c))*12+MONTH(DATEVALUE(experation_date__c)))-
(YEAR( TODAY() )*12+MONTH( TODAY())))) > 3,OR(ISPICKVAL(Status,'Draft'),ISPICKVAL(Status,'Review'))),true,false)
Please Don't Forget To Mark It As Best Answer If It Helps
Thank You!
This was selected as the best answer