+ 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