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
EdithEdith 

Date formula help

Hi,

 

I have the following formula to automatically calculate the end date (start_date__c + 3 month) for all products other than "standard".

However I would like to replace the false IF statement right at the end (null) by [ Month(start_date__c) +12 ] but I get an error message: Error: Incorrect parameter for function 'if()'. Expected Date, received Number

 

Do you know how to stop getting this error?

Thank you,

 

if( PricebookEntry.Product2.Name <> "Standard", DATE(YEAR(Start_Date__c),
MONTH(Start_Date__c)+3,
CASE( MONTH(Start_Date__c)+3,
1, 31,
2, IF( MOD( YEAR(Start_Date__c), 4) = 0, 29, 28),
3, 31,
4, 30,
5, 31,
6, 30,
7, 31,
8, 31,
9, 30,
10, 31,
11, 30,
12, 31,
0 )
), null)

 

Best Answer chosen by Admin (Salesforce Developers) 
Steve :-/Steve :-/

You're missing the DATE function and the YEAR and DAY portions of the DATE(YYYY, MONTH(start_date__c)+12, DD) so the Else result in your formula is basically just shoving a number into the Formula(Date) field. 

All Answers

Steve :-/Steve :-/

Can you post the Formula that is giving you the error?  Also, could you post a screenshot of the error message?  (the location of the error is usually highlighted)

EdithEdith

Hi SteveMo,

 

Here is the formula: 

 

if( PricebookEntry.Product2.Name <> "Standard", DATE(YEAR(Start_Date__c),
MONTH(Start_Date__c)+3,
CASE( MONTH(Start_Date__c)+3,
1, 31,
2, IF( MOD( YEAR(Start_Date__c), 4) = 0, 29, 28),
3, 31,
4, 30,
5, 31,
6, 30,
7, 31,
8, 31,
9, 30,
10, 31,
11, 30,
12, 31,
0 )
), MONTH(start_date__c)+12)  << This statement is giving me the error. 

 

Error: Incorrect parameter for function 'if()'. Expected Date, received Number

 

Thanks 

E


 





EdithEdith

By the way, the error location is not highlighted, I'm going to try in another browser and post. 

Steve :-/Steve :-/

You're missing the DATE function and the YEAR and DAY portions of the DATE(YYYY, MONTH(start_date__c)+12, DD) so the Else result in your formula is basically just shoving a number into the Formula(Date) field. 

This was selected as the best answer
EdithEdith

Thanks SteveMo, I will try and sort this out with your info.

E

Steve :-/Steve :-/

Do you still need help with this or are you all set?

EdithEdith

Hi SteveMo,

It's all good thanks! I'll close this.

Edith