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.

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.

Step 4: Choose Fields & Relationships.
Step 5: Next, select New.

Step 6: Choose the Formula as the field type.
Step 7: Click Next to proceed.

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.

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.

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.

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.

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.

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.

Step 2: Click on the Setup option.

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.

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

Step 6: Select the Formula as the field type.
Step 7: Click Next to proceed.

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.

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.

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.

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.

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.

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:
- Salesforce Date Range Formula
- Salesforce Formula Field to Check Null Values for Dates
- Salesforce Date Formula Business Days
- Salesforce Formula Date Greater Than Today
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.