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
Ken sfdc1Ken sfdc1 

Unable to add createdDate in a opportunity object validation

AND( RecordTypeId = '012L00000000iir',  (Account.Last_Ship_Date__c  > CreatedDate),
ISPICKVAL(Account.AEGR_Pharmacy_Status__c,"Active"),  ISPICKVAL(StageName,"Shipped"))

Can anyone help me on how to add created date in this validation.
Best Answer chosen by Ken sfdc1
Andy BoettcherAndy Boettcher
You can only compare fields of the same type.  The "CreatedDate" field is a date/time field.  You need to add a function to strip out the TIME part.

Try this:
AND( RecordTypeId = '012L00000000iir',  (Account.Last_Ship_Date__c  > DATEVALUE(CreatedDate)),
ISPICKVAL(Account.AEGR_Pharmacy_Status__c,"Active"),  ISPICKVAL(StageName,"Shipped"))

All Answers

Andy BoettcherAndy Boettcher
What error are you getting when trying to save that formula?  Is "Account.Last_Ship_Date__c" a date or date/time field?
Ken sfdc1Ken sfdc1
 Error: Incorrect parameter type for operator '>'. Expected Date, received DateTime
Andy BoettcherAndy Boettcher
You can only compare fields of the same type.  The "CreatedDate" field is a date/time field.  You need to add a function to strip out the TIME part.

Try this:
AND( RecordTypeId = '012L00000000iir',  (Account.Last_Ship_Date__c  > DATEVALUE(CreatedDate)),
ISPICKVAL(Account.AEGR_Pharmacy_Status__c,"Active"),  ISPICKVAL(StageName,"Shipped"))
This was selected as the best answer