Print this page

How to create a Workflow Rule that will add a month to a date?

Knowledge Article Number 000213475
Description How to create a process that will add exactly a month to a date through Workflow Rule with field update.

Considerations:

If it is the end of the month:
**28 February plus one month =31 March
**31 March plus one month =30 April

Checks if it is a leap year or not
Resolution To achieve this following steps need to be taken (This will work on any object which allows workflow). In the example, we will call the date field as Cust_Date

Workflow to determine if the year is a Leap Year
  • Object: Any object where workflow is supported
  • Evaluation Criteria: Evaluate the rule when a record is created, and every time it’s edited 
  • Rule Criteria : MOD((YEAR( <Cust_Date> ) + FLOOR((MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>))) / 12 )), 4 ) = 0 
Field Update if the Year is a Leap Year 
  • Object: Object chosen in the previous step
  • Field to Update: Cust_Date
  • Field Data Type: Date 
  • Formula Value: 
IF( 
MOD( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12 ) = 2 && DAY( <Cust_Date> ) > 29, 

DATE( YEAR( <Cust_Date> ) + FLOOR( ( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>))) / 12 ), MOD(MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12) , (DAY(<Cust_Date>)-ABS(29-DAY(<Cust_Date>)))), 

IF( 
OR( 

MOD( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12 ) = 4, 
MOD( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12 ) = 6, 
MOD( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12 ) = 9, 
MOD( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12 ) = 11 
) && DAY( <Cust_Date> ) > 30, 

DATE( YEAR( <Cust_Date> ) + FLOOR(( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>))) / 12 ), MOD(MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12) , (DAY(<Cust_Date>)-ABS(30-DAY(<Cust_Date>)))), 

DATE( YEAR( <Cust_Date> ) + FLOOR( ( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>))) / 12 ), MOD(MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12) , DAY( <Cust_Date> )))) 

Workflow to determine if it is not a Leap Year

Object: Same object chosen in the previous steps
Evaluation Criteria: Evaluate the rule when a record is created, and every time it’s edited 
Rule Criteria : MOD((YEAR( <Cust_Date> ) + FLOOR((MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>))) / 12 )), 4 ) <> 0 

Field Update for a non-Leap Year 

IF( 
MOD( MONTH( <
Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12 ) = 2 && DAY( <Cust_Date> ) > 28, 
DATE( YEAR( <
Cust_Date> ) + FLOOR( ( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>))) / 12 ), MOD(MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12) , (DAY(<Cust_Date>)-ABS(28-DAY(<Cust_Date>)))), 

IF( 
OR( 
MOD( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12 ) = 4, 
MOD( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12 ) = 6, 
MOD( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12 ) = 9, 
MOD( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12 ) = 11 
) && DAY( <Cust_Date> ) > 30, 

DATE( YEAR( <Cust_Date> ) + FLOOR(( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>))) / 12 ), MOD(MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12) , (DAY(<Cust_Date>)-ABS(30-DAY(<Cust_Date>)))), 

DATE( YEAR( <Cust_Date> ) + FLOOR( ( MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>))) / 12 ), MOD(MONTH( <Cust_Date> ) + VALUE(TEXT(<# of months to add>)), 12) , DAY( <Cust_Date> )))) 

Set the Date field (Cust_Date) to read only through Page Layout
  • Setup | Build | Customize | Contracts | Page Layouts
  • Click on "Edit" link
  • Hover mouse over the Cust_Date field and click on Properties icon (wrench)
  • Tick "Read Only" box
  • Click on "OK" button
  • Click on "Save" button




promote demote