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
MdavoodiMdavoodi 

Create Expiration Date Formula based on Date and Terms selected

Hi there,

I am new to formula creation but have been a SFDC user for years. I am building some custom objects and trying to get this right from the start. 

My business sells a warranty products and I am looking to create a formula field that calculates the "Expiration Date" based on a date field ("Purchase Date") and a picklist ("Term Months") which has 12, 24, 48, 60, etc. which resemble months)

Here is the formula I am using so far but I am getting an error stating "Error: Field Purchase_Date__c may no tbe used in this type of formula

DATE(YEAR(Purchase_Date__c)+(Term_Months__c/12),MONTH(Purchase_Date__c),DAY(Purchase_Date__c))

I am not sure why I am not able to use Purchase Date if its a Date Field...Any ideas? 
manasa udupimanasa udupi
Hi Mdavoodi,

I created same setup and could fix the error, you need to get the value of the picklist field(Term Months) before using it to calculate month.
Hope this helps:)

DATE(YEAR(Purchase_Date__c)+(VALUE(Text(Term_Months__c))/12),MONTH(Purchase_Date__c),DAY(Purchase_Date__c))
MdavoodiMdavoodi
I am still getting the same error. 

Error: Field Purchase_Date__c may not be used in this type of formula
manasa udupimanasa udupi
What is the field Type of each of these three fields
MdavoodiMdavoodi
Expiration Date = Date field
Purchase Date = Date field
Term Months = Picklist
 
manasa udupimanasa udupi
Is Expiration date a Formula field of return type Date?
User-added image