Salesforce Formula Field to Check Null Values for Dates

In this Salesforce tutorial, I will show you how to check null values for dates in Salesforce. We will see, the Salesforce formula field to check null values for dates, in both Salesforce Lightning and Salesforce Classic.

You’ve come to the right place if you want to learn how to check null values for dates in Salesforce. Additionally, we’ll cover how to use Salesforce Lightning and Salesforce Classic to generate a formula field to check null values for dates

While working for an organization that uses Salesforce, I was assigned a job to assign the next available date to a client. So, to fulfill this requirement, I define an advanced formula that checks null values for dates.

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

  • Salesforce formula to check date field is null
  • Check If Date Field Is Null in Salesforce Lightning
  • Check If Date Field Is Null in Salesforce Classic

Salesforce formula to check date field is null

We track different activities in Salesforce, such as when a record was created, when payment is due, or when a task is modified, and for all such activities we use date fields.

So, we build an advance formula to make sure that whether a date field is null or not. Basically, it helps to run the business process smoothly, to analyze data correctly, and to maintain data standards.

To check if a date field is null, we utilized the ISBLANK function of Salesforce. And by default, if the entered date field is null, this function returns a boolean value of true; otherwise, it returns a value of false.

Here, is the syntax to check if a date field is null in a formula field:

ISBLANK(Date_Field)

In the above syntax, Date_Field is the API name of the date field that we want to check if the field is blank.

Let’s understand this concept with the help of an example:

Suppose we are working as a sales manager, and we are responsible for monitoring Salesforce Leads. One day, we notice that in some of the leads Close Date is missing.

To confirm this, we decided to identify if any of the Close Dates are null. So, for this, we create an advance formula given below:

IF(ISBLANK(CloseDate), "Lead Miss the Close Date", "Lead Has Close Date")

With this, we now know about the Salesforce formula to check date field is null. Next, we will move ahead and learn how to check if the date field is null in salesforce lightning.

Check If Date Field Is Null in Salesforce Lightning

Here, are the steps to define a formula that checks if the date field is null 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 Formula Field to Check Null Values for Dates
Salesforce Formula Field to Check Null Values for Dates

Step 3: Look for the item to which we want to check if the date field is null. I choose the Product object from the list of objects in this instance.

Salesforce Formula Field to Check Null Values for Dates
Salesforce Formula Field to Check Null Values for Dates

Step 4: Choose Fields & Relationships.

Step 5: Next, select New.

Salesforce formula to check date field is null
Salesforce formula to check date field is null

Step 6: Choose the Formula as the field type.

Step 7: Click Next to proceed.

Salesforce formula to check date field is null Example
Salesforce formula to check date field is null 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 Delivery Status.

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

Check If Date Field Is Null in Salesforce Lightning
Check If the Date Field Is Null in Salesforce Lightning

Step 10: Enter the check if the date field is the null formula in the Advance Formula editor. Here, is the formula:

IF(ISBLANK(Delivery_Date__c), "Product has not been delivered yet", "Product was delivered on " & TEXT(Delivery_Date__c))
  • In this formula, we check if the Delivery Date field on a product is null or not, and display a message based on the result.
  • To check if the Delivery Date field is null, we use the ISBLANK function.
  • If it is null, the formula returns the text “Product has not been delivered yet”.
  • Otherwise, the formula returns the text “Product was delivered on” with the Delivery Date value. And to convert the delivery date value, we utilized the TEXT function.
  • Then, to connect the delivery date with the text message we use the & operator.

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.

Check If Date Field Is Null in Salesforce Lightning Example
Check If the Date Field Is Null in Salesforce Lightning Example

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.

Check If Date Field Is Null using Salesforce Lightning
Check If the Date Field Is Null using Salesforce Lightning

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.

Check If Date Field Is Null using Salesforce Lightning Example
Check If the Date Field Is Null using Salesforce Lightning Example

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

  • Create a Product with the Delivery Date field by opening the Products item and saving it.
  • After that, click on the Details section, and here the Delivery Status field appears which checks if the date field is null.
Check If Date Field Is Null in Salesforce
When the Delivery Date is Not Null in Salesforce Lightning
Salesforce Check If Date Field Is Null Example
When the Delivery Date is Null in Salesforce Lightning

As a result, we now know how to use Salesforce Lightning’s advance formula to check if the date field is null. Now, we’ll look at how to use the advance formula in Salesforce Classic to check if the date field is null.

Read Salesforce Date Formula Business Days

Check If Date Field Is Null in Salesforce Classic

Here, are the steps to define a formula that checks if the date field is null 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.

Check If Date Field Is Null in Salesforce Classic
Switch to Salesforce Classic

Step 2: Click on the Setup option.

Check If Date Field Is Null in Salesforce Classic Example
Check If Date Field Is Null in Salesforce Classic Setup Example

Step 3: Scroll down to the Build section. Then under Customize, select the object for whom we want to check if the date field is null. Here, I choose the Campaign from the object list.

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

Salesforce Classic Check If Date Field Is Null
Salesforce Classic Check If Date Field Is Null in Campaign

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

Salesforce Classic Check If Date Field Is Null Example
Salesforce Classic Check If Date Field Is Null Example

Step 6: Select the Formula as the field type.

Step 7: Click Next to proceed.

Salesforce Classic formula to check date field is null
Salesforce Classic formula to check date field is null

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

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

Check If Date Field Is Null using Salesforce Classic
Check If Date Field Is Null using Salesforce Classic

Step 10: Enter the formula to check if the date field is null, in the Advance Formula editor. Here, is the formula:

IF(ISBLANK( EndDate ), "Campaign is Ongoing", "Campaign is over, Plan for the new campaign immediately")
  • In this formula, we check if the End Date field on a contract is null or not, and display a message based on the result.
  • To check if the End Date field is null, we use the ISBLANK function.
  • If it is null, the formula returns the text “Campaign is Ongoing”.
  • Otherwise, the formula returns the text “Campaign is over, Plan for the new campaign immediately“.

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.

Salesforce Classic formula to check date field is null example
Salesforce Classic formula to check date field is null example

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.

Salesforce Classic Formula Field to Check Null Values for Dates
Salesforce Classic Formula Field to Check Null Values for Dates

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.

Salesforce Classic Formula Field to Check Null Values for Dates
Salesforce Classic Formula Field to Check Null Values for Dates

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

  • Create a contract with the End Date field value by opening the Contracts tab and saving it.
  • In the details section, we will get the Contract Status field which shows the result based on the check if the date field is null or not.
Salesforce Classic Formula to Check Null Values for Dates
Campaign Status when End Date is not given
Salesforce Formula to Check Null Values for Dates Examples
Campaign Status when End Date is given

We now understand the advanced formula to determine whether the date field is null or not in Salesforce Classic.

Conclusion

In conclusion, we learned the advanced Salesforce formula to check if the date field is null in Salesforce.

Moreover, we have learned that both Salesforce Classic and Salesforce Lightning provide a simple procedure for determining whether the date field is null or not.

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

  • Salesforce formula to check date field is null
  • Check If Date Field Is Null in Salesforce Lightning
  • Check If Date Field Is Null in Salesforce Classic

You may also like the following Salesforce tutorials: