Salesforce Due Date Formula

In this Salesforce tutorial, we will learn the Salesforce Due Date Formula. Additionally, we will go over how to use Salesforce Lightning and Salesforce Classic to create the due date formula field.

I was given the responsibility of keeping track of the record’s due date while working for a company that utilizes Salesforce. Therefore, I define an advanced formula that determines the due date in order to satisfy this need.

If you want to learn how to create a custom due date formula field, you have come to the right place.

The following are the topics that we will cover in this salesforce tutorial:

  • Salesforce Due Date Formula
  • Formula to calculate Due Date in Salesforce Lightning
  • Formula to calculate Due Date in Salesforce Classic

Salesforce Due Date Formula

In Salesforce, to keep track of that our tasks and projects are completed on time and in an efficient manner, we need a due date. So, for this, we need to create a due date formula field as per requirement.

To create the due date formula, Salesforce provides us with various built-in functions that help us to set it based on criteria. Let’s see some of the commonly used cases of the due date formula in Salesforce.

Due Date based on the specified number of days:

In a simple case, we calculate the due date based on the created, started, payment date, and a specified number of days.

Here is the formula:

DATEVALUE(Created/Started/PaymentDate) + No.of.days
  • This formula is used to calculate the due date based on the specific number of days to add.
  • Here, we use the DATEVALUE function to convert the Created/Started/PaymentDate if given in date and time data type to date value.
  • Then, No.of.days is the API name that stores the number of days to add to the Created/Started/PaymentDate.

Due Date based on specific days of the month:

In this case, we calculate the due date based on specific days of the month.

Here is the formula:

IF(DAY(Created/Started/PaymentDate) <= 18, 
   DATE(YEAR(Created/Started/PaymentDate), MONTH(Created/Started/PaymentDate), 18), 
   DATE(YEAR(Created/Started/PaymentDate), MONTH(Created/Started/PaymentDate) + 1, 1)) 
+ No.of.Days
  • Here, we use the IF function that checks the day of the month when the record was created, started or the payment date is less than or equal to 18.
  • If it is, the formula uses the DATE function to create a new date using YEAR, MONTH, and day 18th of that month.
  • If the Created/Started/PaymentDate is after the 18th, the formula uses the DATE function to create a new date using YEAR, set month to the next month and day to the 1st of that month.
  • Then, to calculate the due date, add the number of days.

We can use any of the above-defined formulas by creating a custom formula field in Salesforce. Let’s move to the next section and learn to create a formula field on the object where we want to set the due date.

With this, we now know about the Salesforce Due Date Formula. Next, we will move ahead and learn how to set the due date in Salesforce Lightning.

Formula to calculate Due Date in Salesforce Lightning

Here, are the steps to define the formula to calculate the due date in Salesforce Lightning.

Step 1: Click the Setup icon in the top right corner of the page to access Salesforce Setup.

Step 2: Click Object Manager from the menu’s left side.

Salesforce Due Date Formula
Salesforce Due Date Formula

Step 3: Look for the item to which we want to set the due date. In this example, I choose the Product object from the list of objects.

Salesforce Due Date Formula Example
Salesforce Due Date Formula Example

Step 4: Choose Fields & Relationships.

Step 5: Next, select New.

Salesforce Due Date Formula Example
Salesforce Due Date Formula Example

Step 6: Choose the Formula as the field type.

Step 7: Click Next to proceed.

Salesforce Lightning Due Date Formula Example
Salesforce Lightning Due Date Formula Example

Step 8: After entering a Field Label for the formula, the Field Name will be filled in automatically. Here, I enter Field Label as the Payment Due Date.

Step 9: Select Date as the Formula Return Type. After that, click Next.

Formula to calculate Due Date in Salesforce Lightning
Formula to calculate Due Date in Salesforce Lightning

Step 10: Enter the formula that calculates the due date in the Advance Formula editor. The formula is given below:

Payment_Date__c +5 

In this formula, we add 5 days to a date value stored in a field called “Payment_Date__c”. It helps us to calculate the due date by adding a number of days to an existing payment date.

Step 11: To verify that the formula is valid, click Check Syntax.

Step 12: We can specify how you want to handle the empty field and include the Description and Help Text as alternatives.

Step 13: Then, select Next.

Formula to calculate Due Date in Salesforce Lightning Example
Advance formula to calculate Due Date

Step 14: Select the appropriate field Level Security and to make it visible to everyone, here we select the Visible checkbox.

Step 15: Select Next.

Formula to calculate Due Date using Salesforce Lightning
Formula to calculate Due Date Fiel Level Security

Step 16: Select the Page Layout Name for which the formula field is to be added.

Step 17: Click Save to save the formula field.

Formula to calculate Due Date using Salesforce Lightning Example
Formula to calculate Due Date

We can use the formula field once we’ve created it. Let’s look at an example:

  • Create a product with a payment date field by opening the Products item and saving it.
  • After that, click on the Details section, and here the Payment Due Date field appears.
Salesforce Lightning Formula to calculate Due Date
Salesforce Lightning Formula to calculate Due Date

As a result, we now know how to use Salesforce Lightning’s advance formula to set the due date. Now, we’ll look at how to use the advance formula in Salesforce Classic to calculate the due date.

Read Salesforce Last Activity Date Formula

Formula to calculate Due Date in Salesforce Classic

Here, are the steps to define the formula to calculate the due date in Salesforce Classic.

Step 1: From the Salesforce Lightning to open your Salesforce Classic edition. Click on Avtar and then click Switch to Salesforce Classic.

Formula to calculate Due Date in Salesforce Classic
Switch to Salesforce Classic

Step 2: Click on the Setup option.

Formula to calculate Due Date in Salesforce Classic Example
Formula to calculate Due Date in Salesforce Classic Setup

Step 3: Scroll down to the Build section. Then under Customize, select the object for whom we want to calculate the due date. Here, I choose the Campaigns from the object list.

Step 4: Click on the dropdown menu and select Fields.

Formula to calculate Due Date using Salesforce Classic
Formula to calculate Campaign Due Date using Salesforce Classic

Step 5: As you scroll down the page, click on the New button under Custom Fields & Relationships.

Formula to calculate Due Date using Salesforce Classic Example
Formula to calculate Due Date using Salesforce Classic Example

Step 6: Select the Formula as the field type.

Step 7: Click Next to proceed.

Salesforce Classic Due Date Formula
Salesforce Classic Due Date Formula

Step 8: Enter a Field Label for the formula, and the Field Name will be automatically populated. Here, I enter Field Label as Campaign Due Date.

Step 9: Select Date as the Formula Return Type. After that, click Next.

Salesforce Classic Due Date Formula Example
Salesforce Classic Due Date Formula Example

Step 10: Enter the formula that calculates the due date in the Advance Formula editor. The formula is given below:

IF(DAY( StartDate ) <= 18,
DATE(YEAR(StartDate), MONTH(StartDate), 18),
DATE(YEAR(StartDate), MONTH(StartDate) + 1, 1))
+ 7
  • In this formula, we calculate the Campaign Due Date on the base of StartDate.
  • If the day of the month is less than or equal to 18, the formula returns the 18th of the same month and year as the start date.
  • If the day of the month is greater than 18, the formula returns the 1st of the next month and year as the start date.
  • Then, we add 7 days to the above-calculated date and the resultant date is the due date.

Step 11: To verify that the formula is valid, click Check Syntax.

Step 12: We can specify how you want to handle the empty field and include the Description and Help Text optionally.

Step 13: Then, click Next.

Due Date Formula Salesforce Classic
Due Date Formula Salesforce Classic

Step 14: Choose the appropriate Field’s Level Security, and then check the box Visible to make it visible to all.

Step 15: Click Next.

Due Date Formula Salesforce Classic Example
Due Date Formula Salesforce Classic Field Level Security

Step 16: Choose the Page Layout Name for which the formula field is to be added.

Step 17: Click Save to save the formula field.

Calculate Due Date in Salesforce Classic
Calculate the Due Date in Salesforce Classic

Once we’ve defined the formula field, we may use it. Let’s explore an example:

  • Create a campaign by opening the Campaigns tab and saving it.
  • Then, in the detail section, we will get the Campaign Due Date field which shows the due date.
Calculate Due Date in Salesforce Classic Example
Calculate Due Date in Salesforce Classic Example

We now understand the advanced formula to determine the due date in Salesforce Classic.

Conclusion

With this, we have learned the Salesforce Due Date Formula. Moreover, we have learned the simple procedure for setting the due date in both Salesforce Classic and Salesforce Lightning.

In addition to this, the following are the topics that we have discussed:

  • Salesforce Due Date Formula
  • Formula to calculate Due Date in Salesforce Lightning
  • Formula to calculate Due Date in Salesforce Classic

You may also like the following Salesforce tutorials: