2

Suppose i have createddate as 05-05-2016 then formula field 1 should be 042016 and formula field 2 should be 032016.

Two Exceptional cases are:

  1. if i have createddate 01-01-2016 (January) then formula field 1 should be 122015 and formula field 2 should be 112015
  2. if i have createddate 02-02-2016 (February) then formula field 1 should be 012016 and formula field 2 should be 122015

Is it possible to get such formula field

  • For formula field 1 i am trying like below : IF((MONTH(Invoice_Date__c ))>=3 ,TEXT(MONTH(Invoice_Date__c )-1) + TEXT(YEAR(Invoice_Date__c)) , IF((MONTH(Invoice_Date__c ))=2,TEXT(MONTH(Invoice_Date__c )-1) + TEXT(YEAR(Invoice_Date__c)), IF((MONTH(Invoice_Date__c ))=1,'12' + TEXT(YEAR(Invoice_Date__c)-1),null ) ) ) – Jack vardy Aug 24 '16 at 12:18
1

You can try the following formula:

IF(MONTH(Invoice_Date) > 1, 
  (MONTH(Invoice_Date__c) - 1) + '' + YEAR(Invoice_Date__c), 
  '12' + (YEAR(Invoice_Date__c)-1))

The logic behind. Suppose we have a 01.01.2016:

  • IF the month of the given date is in the range of 2 - 12:
    • output: (month -1 ) & year ---> for the 01.05.2016 -> 42016
  • IF the month is 1:
    • output: (month => 12) & year => (2016 - 1) ---> for the 01.01.2016 -> 122015
0

Formula Field 1 :

IF((MONTH(Invoice_Date__c ))>=3 ,TEXT(MONTH(Invoice_Date__c )-1) + TEXT(YEAR(Invoice_Date__c)) ,
IF((MONTH(Invoice_Date__c ))=2,TEXT(MONTH(Invoice_Date__c )-1) + TEXT(YEAR(Invoice_Date__c)),
IF((MONTH(Invoice_Date__c ))=1,'12' + TEXT(YEAR(Invoice_Date__c)-1),null
)
)
)

Formula Field 2:

IF((MONTH(Invoice_Date__c ))>=3 ,TEXT(MONTH(Invoice_Date__c )-2) + TEXT(YEAR(Invoice_Date__c)) ,
IF((MONTH(Invoice_Date__c ))=2,'12' + TEXT(YEAR(Invoice_Date__c)-1),
IF((MONTH(Invoice_Date__c ))=1,'11' + TEXT(YEAR(Invoice_Date__c)-1),null
)
)
)
0

For field 1 you can use this formula:

TEXT(IF(MONTH(StartDate__c) = 1, 12, MONTH(StartDate__c)-1))&""&TEXT(IF(MONTH(StartDate__c) = 1 ,(YEAR(StartDate__c)-1), YEAR(StartDate__c)))

For field 2, you can use formula from field 1:

TEXT(IF(MONTH(formulafield1) = 1, 12, MONTH(formulafield1)-1))&""&TEXT(IF(MONTH(formulafield1) = 1 ,(YEAR(formulafield1)-1), YEAR(formulafield1)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.