Add Days to Date in Salesforce Formula

In this Salesforce Tutorial, we will learn the formula to Add Day to Date in Salesforce. Moreover, we will go through the steps using which we can Add the Day to Date Field in Salesforce Lightning and Salesforce Classic.

In Salesforce, there are many scenarios where we need to Add Day to Date in Salesforce, such as calculating an expected delivery date, or the due date of a task, scheduling follow-up tasks, payment due date, etc.

And, In all these situations, we need to Add Day to Date in Salesforce. So, If you want to explore How to Add Day to Date in Salesforce Lightning and Classic Edition, you have come to the right place.

The following are the topics that we will cover in this Salesforce Tutorial:

  • How to add Day to Date in Salesforce
  • Add Day to Date in Salesforce Lightning
  • Add Day to Date in Salesforce Classic

How to add Day to Date in Salesforce

In Salesforce, to add a specific number of days in a Date value, we use the Salesforce Date() and Day() functions together.

Here is the syntax to add Day to Date in Salesforce:

DATE(YEAR(date_field),MONTH(date_field),DAY(date_field) + No.of days )

Here, we use:

  • Date() function: It is used to store the date of the object in YYY-MM-DD format.
  • Year() function: It is used to extract the year from the date.
  • Month() function: It is used to extract the month from the date.
  • Day() function: It is used to extract the day from the date.
  • No. of Days: It is the number of days that we want to add to a day.

In this code, The API name of the date field we want to add a day to should be entered for the Date Field. And this formula returns a new date that is one day after the original.

Let’s understand it in detail with the help of an example:

Let’s say we want to create a formula to determine the Payment Due Date of the Product by adding 2 days to the Purchase Date. And, Here is the formula for this:

DATE(YEAR(Purchase_Date__c), MONTH(Purchase_Date__c), DAY(Purchase_Date__c) + 2)

With, this we have learned the formula to add days to date in salesforce. Now, we will move further and see How to Add Day to Date in Salesforce Lightning.

See also  Difference between Two Datetime Fields in Salesforce

Read Salesforce Formula Add Year to Date

Add Day to Date in Salesforce Lightning

Here, are the steps to Add Day to Date using the Advance Formula in Salesforce Lightning.

Step 1: Navigate to salesforce Setup, by clicking on the Setup icon on the upper right side of the page.

Step 2: On the nav bar, click on Object Manager.

Add Day to Date in Salesforce Lightning
Add Day to Date in Salesforce Lightning

Step 3: Search for the object to which we want to add a day to the date field. Here, I select the Products object from the list of objects.

Add Day to Date in Salesforce Lightning Example
Add Day to Date in Salesforce Lightning Example

Step 4: Click on Fields & Relationships.

Step 5: Then, click on New.

Add Day to Date in Salesforce Lightning using advance formula
Add Day to Date using Advance Formula

Step 6: Choose the Formula as the field type.

Step 7: To continue, click Next.

add day to date in salesforce lightning using advance formula example
Add Day to Date in Salesforce

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

Step 9: Choose Date as the Formula Return Type and then click Next.

How to add Day to Date in Salesforce
How to add Day to Date in Salesforce

Step 10: Enter the Add Day to Date formula in the Advance Formula editor. Here, is the formula:

DATE(YEAR(Purchase_Date__c), MONTH(Purchase_Date__c), DAY(Purchase_Date__c) + 3)
  • In this formula, we first store the date using the Date function. After that, we fetch out the year, month, and day from the date field using the YEAR, MONTH, and DAY Salesforce functions.
  • Next, we add 3 as the number of days that we want to add to the Day of the Date.

Step 11: Click Check Syntax to make sure the formula is correct.

Step 12: We can add the Description and Help Text as options, and we can also state how you want to handle the blank field.

Step 13: After that, click Next.

How to add Day to Date in Salesforce Example
Add Day to Date in Salesforce Example

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

See also  Salesforce Formula Add Year to Date

Step 15: Select Next.

add days to date in salesforce formula
Add Days to Date in Salesforce Formula

Step 16: Choose the Page Layout Name, for whom we want to add the formula field.

Step 17: To save the formula field, click Save.

add days to date in salesforce formula example
Days to Date in Salesforce Formula Example

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

  • Create a new product using the Purchase Date value by opening the Products object and saving it.
  • After that, click on the Details section, and here the Payment Due Date field will appear with the date value having three additional days.
example to add days to date in salesforce formula
Example to Add Days to Date in Salesforce Formula

As a result, we now know how to use Salesforce Lightning’s advanced formula to add the Day to the Date field. Next, we’ll look at how to use Salesforce Classic’s advance formula to add Day to the Date field.

Add Day to Date in Salesforce Classic

Here, are the steps to Add Day to Date using the Advance Formula in Salesforce Classic.

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

Add Day to Date in Salesforce Classic
Switch to Salesforce Classic

Step 2: Click on the Setup option.

Add Day to Date in Salesforce Classic Example
Salesforce Classic Setup

Step 3: Scroll down to the Build section. Then under Customize, select the object for whom we want to add Day to Date. Here, I choose the Leads from the object list.

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

how to add day to date in salesforce classic
Add Day to Date

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

how to add day to date in salesforce classic example
Add Day to Date in Salesforce Classic Example

Step 6: Select the Formula as the field type.

Step 7: Click Next to proceed.

salesforce classic add day to date example
Add Day to Date Salesforce Formula

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

Step 9: Choose Date as the Formula Return Type and then click Next.

how to add day to date in salesforce classic using advance formula
Day to Date Salesforce Example

Step 10: The Advance Formula editor to enter the Add Day to Date formula. The formula is as follows:

DATE(YEAR(Lead_Start_Date__c), MONTH(Lead_Start_Date__c), DAY(Lead_Start_Date__c) + 1)
  • Using the DATE function, we first save the date in this formula.
  • Then, using the YEAR, MONTH, and DAY Salesforce functions, we retrieve the year, month, and day from the date field.
  • Then, we add the desired number of days, in this case, we add 1 as the Day of the Date.
See also  MID Function in Salesforce | How to get substring in Formula Field in Salesforce

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.

how to add day to date in salesforce classic using advance formula example
Advance Formula to Convert Day to Date

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.

add days to date in salesforce classic formula
Salesforce Classic Add Day to Date

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.

add days to date in salesforce classic formula example
Page Layout to Add Day to Date Salesforce Formula

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

Create a new product using the Start Date value by opening the Leads object and saving it. After that, click on the Details section, and here the Lead Due Date field will appear with the date value having one extra day.

salesforce classic add day to date
Salesforce Classic Add Day to Date

In a conclusion, we now understand how to add the Day to Date using Salesforce Classic’s advanced formula.

You may also like:

Conclusion

In conclusion, we have learned the advance salesforce formula to add Day to Date. Moreover, we have learned that both Salesforce Classic and Salesforce Lightning provide a simple procedure to Add the Day to Date Field.

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

  • How to add Day to Date in Salesforce
  • Add Day to Date in Salesforce Lightning
  • Add Day to Date in Salesforce Classic