0

I have a formula field which don't have syntax errors. The characters in this formula has not even more than 500 characters. But, it is showing 2,535 characters. I need this formula as much as possible in very less characters and the formula is given below.

DATETIMEVALUE (DATE(

  YEAR(DATEVALUE( Exact_Date__c )) + FLOOR( ( MONTH (DATEVALUE( Exact_Date__c )) + 2 - 1 ) / 12 ),

  MOD( MONTH (DATEVALUE( Exact_Date__c )) + 2 - 1 + 
    IF( DAY (DATEVALUE( Exact_Date__c )) > CASE( MOD( MONTH (DATEVALUE( Exact_Date__c )) + 2 - 1, 12 ) + 1, 

      2, 28,

      4, 30,

      6, 30,

      9, 30, 

      11, 30,

      31 ), 1, 0 ), 12 ) + 1,

    IF( DAY(DATEVALUE( Exact_Date__c )) > CASE( MOD( MONTH (DATEVALUE( Exact_Date__c )) + 2 - 1, 12 ) + 1,

      2, 28, 

      4, 30, 

      6, 30, 

      9, 30, 

      11, 30, 

      31 ), 

    1, DAY(DATEVALUE( Exact_Date__c ))

   )
  )
)

Where Exact_Date__c is a Date-Time filed which works as input field takes date and time from object.

Specifically, why i need this requirement, i am using this formula field in another formula field which results in character error more than 5000.

I tried with breaking the formula field into multiple fields as in reference 1 is saying, but giving same result in characters.

I followed through following references. But its returning same result.

These are the reference 1 and reference 2

could any one help me how i can reduce the formula characters?

9
  • normally to reduce number of character we break the formula into multiple field. Check if you can try that. As limit is 5000 char I don't see any issue with 2,535 char. Is there any specific reason. Commented Jan 4, 2017 at 12:18
  • Yes @ Tushar Sharma. I forget to explain why i need this specifically. I am using this formula field in another formula field which results in character error more than 5000.
    – KS Kumaar
    Commented Jan 4, 2017 at 12:22
  • 2
    Though it probably won't help you too much in this situation, there's another question here that goes over the compiled sizes of Salesforce formula functions.
    – Derek F
    Commented Jan 4, 2017 at 12:49
  • My guess would be that Dup__c is itself a formula field. If that's the case, please edit your question to include that formula field as well. Seeing as its used 8 times in the formula field you're asking about, optimizations to that field are more valuable than optimizations to the formula field you're currently asking about.
    – Derek F
    Commented Jan 4, 2017 at 12:51
  • You might also get some other suggestions for formula fields if you mention exactly what it is that you're trying to accomplish with these formula fields. I can guess this one has something to do with knowing how many days are in each month, but that's about it.
    – Derek F
    Commented Jan 4, 2017 at 12:54

0

You must log in to answer this question.

Browse other questions tagged .