Salesforce Formula: Check if Date Greater Than Specific Date

I was given a task while employed by an organization to determine whether a date exceeds a certain date. It enables us to streamline workflows and processes depending on particular dates, as well as better manage and organize our data in Salesforce.

In this article, we will learn how to check if a date is greater than a specific date using a Salesforce Formula.

Salesforce Formula to Confirm if a Date is Greater Than a Specific Date

In Salesforce, to compare a date field with a predefined date value to see if the date is greater than the particular date, we create an advance formula field that finds whether a date is greater than a particular date or not.

In Salesforce, for comparing the set date value with the date field, we use the comparison operators Greater Than (>) or Greater Than or Equal to (>=).

For example, we want to check if the Cose Date field of a Case is greater than Today. So, for this, we define a Salesforce formula that looks like as follows:

IF( CloseDate > TODAY(), "True", "False")

In this formula, the CloseDate field is compared to the result of the TODAY function. If the CloseDate is after today’s dates, the formula will return TRUE. Otherwise, it will return FALSE.

We can use this formula in various situations, including triggering workflows and automation, sorting and filtering data, and generating fields based on specific dates, among other applications.

Salesforce Formula: Check if Date Greater Than Specific Date

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

  1. Click the Setup icon in the top right corner of the page to access Salesforce Setup.
    • Click “Object Manager” from the Navigation Bar.
Salesforce formula to confirm if date is greater than a specific
  1. Look for the item to which we want to compare a date that is greater than a certain date. I choose the Product object from the list of objects in this instance.
Salesforce formula to confirm if date is greater than a specific example
  1. Choose Fields & Relationships. Next, select New.
Salesforce advance formula to confirm if date is greater than a specific
  1. Choose the Formula as the field type. Click Next to proceed.
Salesforce advance formula to confirm if date is greater than a specific example
  1. After entering a Field Label for the formula, the Field Name will be filled in automatically. Here, I enter Field Label as the Amount + Extra Charge.
    • Select Currency as the Formula Return Type. After that, click Next.
Formula date greater than specific date in Salesforce Lightning
  1. Enter the date greater than the specific date formula in the Advance Formula editor. Here is the formula:
IF(Payment_Due_Date__c > Purchase_Date__c + 5,
    IF(Payment_Due_Date__c > Purchase_Date__c + 10, Price__c + 100, Price__c + 50),
Price__c
)
  • The IF() function is used in this formula to determine whether the payment due date is greater than the Purchase Date + 5 Days.
  • If so, a second IF() function is used to determine whether the payment deadline exceeds the Purchase Date + 10 Days.
  • If so, the price is increased by 100 rupees “Price__c + 100”. If not, the price is increased by 50 rupees “Price__c + 50”.
  • The formula returns the original price “Price__c” if the payment due date is not more than 5 days after the Purchase Date.
  1. 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.
Formula date greater than specific date in Salesforce Lightning Example
  1. Select the appropriate field Level Security, and to make it visible to everyone, we select the Visible checkbox.
    • Select Next.
Advance formula date greater than specific date in Salesforce Lightning
  1. Select the Page Layout Name for which the formula field is to be added.
    • Click Save to save the formula field.
Advance formula date greater than specific date in Salesforce Lightning Example
  1. We can use the formula field once it has been created. Let’s look at an example:
    • Create a Product with the Payment Due Date, Purchase Date, and Price fields by opening the Products item and saving it.
    • After that, click on the Details section, and here the Amount + Extra Charge field appears which shows how the formula date is greater than the specific date works.
Date greater than specific date in Salesforce Lightning
When the Payment Due Date is less than the Purchase Date + 5 Days
Date greater than specific date in Salesforce Lightning Example
When the Payment Due Date is greater than the Purchase Date + 5 Days.
Salesforce Formula date greater than specific date

When the Payment Due Date is greater than the Purchase Date + 10 Days.

Conclusion

In conclusion, we learned the advanced salesforce formula to check the date greater than the specific date.

Moreover, we have learned that both Salesforce Classic and Salesforce Lightning offer a straightforward procedure for checking if a date is greater than a specific date.

You may also like to read:

Agentforce in Salesforce

DOWNLOAD FREE AGENTFORCE EBOOK

Start with AgentForce in Salesforce. Create your first agent and deploy to your Salesforce Org.

Salesforce flows complete guide

FREE SALESFORCE FLOW EBOOK

Learn how to work with flows in Salesforce with 5 different real time examples.