Salesforce Formula Date Less Than Today

You’ve come to the right place if you want to learn about Salesforce’s Advance Formula Date Less Than Today. Additionally, we’ll cover how to use Salesforce Lightning and Salesforce Classic to generate a formula date less than today.

While working for an organization, I was assigned a job to determine whether a date is less than the current date. It enables us to manage and organize our data in Salesforce more effectively, as well as streamline workflows and processes based on today’s date.

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

  • Salesforce Formula for Date Less Than Today
  • Formula for Date Less Than Today in Salesforce Lightning
  • Formula for Date Less Than Today in Salesforce Classic

Salesforce Formula for Date Less Than Today

In Salesforce, we build an advance formula field that determines whether a date is less than a today date or not in order to compare a date field with a today date value to check if the date is less than the today date.

In Salesforce, we utilize the comparison operators Less Than (<) or Less Than or Equal to (<=) to compare the value of the set date with the today field.

For instance, we want to see if the object’s date field is less than today. Therefore, we define a Salesforce formula that looks like this:

DateField < TODAY()
                #OR
DateField <= TODAY()

In this formula, we check if the date field is less than today’s date. For this, we use the TODAY() function, less or equal operator, and compare it with the date field.

This formula can be applied in a wide range of situations, such as triggering workflows and automated processes, sorting and filtering data, creating fields depending on today’s date, etc.

In conclusion, we now know how to check in Salesforce if a date is less than today’s date using a formula. The next step is to learn how to use Salesforce Lightning to verify dates that are before today date.

Read Salesforce Formula Date Greater Than Specific Date

Formula for Date Less Than Today in Salesforce Lightning

Here, are the steps to define a formula date less than today’s date in Salesforce Lightning.

  • Click the Setup icon in the top right corner of the page to access Salesforce Setup.
  • Click Object Manager from the menu’s left side.
Salesforce Formula for Date Less Than Today
Salesforce Formula for Date Less Than Today
  • Look for the item to which we want to compare a date that is less than today’s date. I choose the Contract object from the list of objects in this instance.
Salesforce Formula for Date Less Than Today Example
Salesforce Formula for Date Less Than Today Contract Example
  • Choose Fields & Relationships.
  • Next, select New.
Formula for Date Less Than Today in Salesforce Lightning
Formula for Date Less Than Today in Salesforce Lightning
  • Choose the Formula as the field type.
  • Click Next to proceed.
Formula for Date Less Than Today in Salesforce Lightning Example
Formula for Date Less Than Today in Salesforce Lightning Data Type
  • After entering a Field Label for the formula, the Field Name will be filled in automatically. Here, I enter Field Label as Validation.
  • Select Text as the Formula Return Type. After that, click Next.
Date Less Than Today in Salesforce Lightning
Date Less Than Today in Salesforce Lightning
  • Enter the date less than today’s date formula in the Advance Formula editor. Here, is the formula:
IF( EndDate  < TODAY(), "Contract time period is over. Please renew it.", "Contract is valid for " & TEXT( EndDate - TODAY()) & " days.")

The IF function determines whether the contract end date called “EndDate” is less than the current day called “TODAY()”. If so, the text “Contract time period is over. Please renew it” is returned.

Otherwise, it returns the text “Contract is valid for X days”, where X represents the number of days remaining until the contract end date.

The number of days left is converted into text using the TEXT function so that it can be included with the text using & the concatenation operator.

  • To verify that the formula is valid, click Check Syntax.
  • We can specify how you want to handle the empty field and include the Description and Help Text as alternatives.
  • Then, select Next.
Date Less Than Today in Salesforce Lightning Example
Date Less Than Today in Salesforce Lightning Example
  • Select the appropriate field Level Security and to make it visible to everyone, here we select the Visible checkbox.
  • Select Next.
Advance Formula for Date Less Than Today in Salesforce Lightning
Advance Formula for Date Less Than Today Field Level Security
  • Select the Page Layout Name for which the formula field is to be added.
  • Click Save to save the formula field.
Advance Formula for Date Less Than Today in Salesforce Lightning Example
Advance Formula for Date Less Than Today Page Layout

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

  • Create a Contract with the Contract Start Date, and Contract Term fields by opening the Contracts item and saving it.
  • After that, click on the Details section, and here the Validation field appears which shows how the formula date is less than today’s date works.
Salesforce Lightning Formula for Date Less Than Today Example
When the End Date is more than today’s date it prints “Contract time period is over. Please renew it”.
Salesforce Lightning Formula for Date Less Than Today
When the End Date is less than today’s date it prints “Contract is valid for X days”.

As a result, we now understand how to use the advance formula date less than today’s date in Salesforce Lightning. Next, we’ll look at how to check a date that is less than today using the advance formula in Salesforce Classic.

Read Salesforce Formula Field to Calculate Age

Formula for Date Less Than Today in Salesforce Classic

Here, are the steps to define a formula date greater than the specific date in Salesforce Classic.

  • From the Salesforce Lightning to open your Salesforce Classic edition. Click on Avtar and click Switch to Salesforce Classic.
Formula for Date Less Than Today in Salesforce Classic
Formula for Date Less Than Today in Salesforce Classic
  • Click on the Setup option.
Formula for Date Less Than Today in Salesforce Classic Example
Formula for Date Less Than Today in Salesforce Classic Example
  • Scroll down to the Build section. Then under Customize, select the object for whom we want to compare a date that is less than a current date. Here, I choose the Products from the object list.
  • Click on the dropdown menu and select Fields.
Date Less Than Today in Salesforce Classic
Date Less Than Today in Salesforce Classic Products Object
  • As you scroll down the page, click on the New button under Custom Fields & Relationships.
Date Less Than Today in Salesforce Classic Example
Date Less Than Today in Salesforce Classic Example
  • Select the Formula as the field type.
  • Click Next to proceed.
Advance Formula for Date Less Than Today in Salesforce Classic
Advance Formula for Date Less Than Today Data Type
  • Enter a Field Label for the formula, and the Field Name will be automatically populated. Here, I enter Field Label as Extra Charge.
  • Choose Currency as the Formula Return Type and then click Next.
Advance Formula for Date Less Than Today in Salesforce Classic Example
Advance Formula for Date Less Than Today in Salesforce Classic Example
  • Enter the date less than today’s date formula in the Advance Formula editor. Here, is the formula:
IF( Payment_Due_Date__c  < TODAY(),( TODAY() - Payment_Due_Date__c) * 5, 0 )

The IF function determines whether the product’s payment due date called “Payment_Due_Date__c” is today or later.

If so, it returns the number of days remaining until the payment due date using the formula and multiplies it by 5 to calculate the extra charges. Otherwise, it returns 0 as the extra charge.

  • To verify that the formula is valid, click Check Syntax.
  • We can specify how you want to handle the empty field and include the Description and Help Text optionally.
  • Then, click Next.
Salesforce Classic Formula for Date Less Than Today Example
Salesforce Classic Formula for Date Less Than Today Example
  • Choose the appropriate Field’s Level Security, and then check the box Visible to make it visible to all.
  • Click Next.
Salesforce Classic Formula for Date Less Than Today
Field Level Security Formula for Date Less Than Today
  • Choose the Page Layout Name for which the formula field is to be added.
  • Click Save to save the formula field.
Formula for Date Less Than Today using Salesforce Classic
Formula for Date Less Than Today Page Layout

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

  • Create a new product with the Payment Due Date field value by opening the Products tab and saving it.
  • In the details section, we will get the Extra Charges field which shows how the formula date is less than today’s date works.
Date Less Than Today Salesforce Classic Formula
When Payment Due Date is less than Today
Formula for Date Less Than Today using Salesforce Classic Example
When Payment Due Date is more than Today

In a conclusion, we now understand the formula date is less than today’s date.

You may also like to read:

Conclusion

In conclusion, we learned the advanced salesforce formula to check the date is less than the current date.

Moreover, we have learned that both Salesforce Classic and Salesforce Lightning provide a simple procedure for checking the date less than today’s date.

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

  • Salesforce Formula for Date Less Than Today
  • Formula for Date Less Than Today in Salesforce Lightning
  • Formula for Date Less Than Today in Salesforce Classic

Read ABS() Function in Salesforce | Calculate absolute value in Salesforce