Salesforce Formula DATETIMEVALUE

In this Salesforce Tutorial, we will learn the Salesforce Advance DateTimeValue formula. Moreover, we will go through the steps of using the DateTimeValue formula in Salesforce Lightning and Salesforce Classic.

While working in an organization that uses Salesforce as a CRM tool, I got a task where I need to convert the expression to date/time value. So, to fulfill this requirement, I use the date/time functionality of Salesforce.

If you want to learn How to use DateTimeValue Advance Formula in Salesforce Lightning and Salesforce Classic, you have come to the right place.

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

  • How to use DATETIMEVALUE Formula in Salesforce Lightning
  • How to use DATETIMEVALUE Formula in Salesforce Classic

https://youtu.be/BjdsDm2POAI

How to use DATETIMEVALUE Formula in Salesforce Lightning

Here, are the steps to use the DATETIMEVALUE Advance Formula in Salesforce Lightning.

Step 1: Click the Setup icon in the top right corner of the page to access Salesforce Setup.

Step 2: Select Object Manager from the menu’s left side.

How to use DATETIMEVALUE Formula in Salesforce Lightning
DATETIMEVALUE Formula in Salesforce Lightning

Step 3: Look for the item we wish to get the Date and Time. I choose the Contact object from the list of objects in this instance.

How to use DATETIMEVALUE Formula in Salesforce Lightning Example
DATETIMEVALUE Formula in Salesforce Contact Object

Step 4: Click on Fields & Relationships.

Step 5: Next, Select New.

Use DATETIMEVALUE Formula in Salesforce Lightning
DATETIMEVALUE Formula in Salesforce Lightning

Step 6: Choose the Formula as the field type

Step 7: Click Next to proceed.

Use DATETIMEVALUE Formula in Salesforce Lightning Example
DATETIMEVALUE Formula in Salesforce Lightning Example

Step 8: After entering a Field Label for the formula, the Field Name will be filled in automatically. I have Field Label as the Create Contact Time Date in this instance.

Step 9: Select the Date/Time return type for the formula. Next, select Next.

DATETIMEVALUE Formula in Salesforce Lightning
DATETIMEVALUE Formula in Salesforce Lightning

Step 10: Fill out the Advance Formula editor with the DATETIMEVALUE formula. The formula is as follows:

DATETIMEVALE(CreatedDate)
  • In this formula, we use the DATETIMEVALUE() formula to get the date and time of the contact created.
  • Here, we pass the CreatedDate as a field to the function.

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

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

Step 13: Then, select Next.

DATETIMEVALUE Formula in Salesforce Lightning Example
DATETIMEVALUE Formula 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.

DATETIMEVALUE Formula in Salesforce
DATETIMEVALUE Formula in Salesforce

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.

DATETIMEVALUE Formula in Salesforce Example
DATETIMEVALUE Formula in Salesforce Example

Once we’ve set up the formula field, we may use it. Let’s examine an illustration:

  • Create a Contact by opening the Contacts tab and saving it.
  • After that, choose the Details tab. In this window, the Create Contact Time Date field will show the time and date when the contact was created.
DATETIMEVALUE Advance Formula in Salesforce Lightning
DATETIMEVALUE Advance Formula in Salesforce Lightning

As a result, we now know how to use Salesforce Lightning’s advanced formula to get the DateTime from the field. Next, we’ll look at how to use Salesforce Classic’s advance formula to get the DateTime value from the date.

Read Salesforce Weekday Formula

How to use DATETIMEVALUE Formula in Salesforce Classic

Here, are the steps to use the DATETIMEVALUE 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.

How to use DATETIMEVALUE Formula in Salesforce Classic
Switch to Salesforce Classic

Step 2: Click on the Setup option.

How to use DATETIMEVALUE Formula in Salesforce Classic Example
DATETIMEVALUE Formula in Salesforce Classic Example

Step 3: Scroll down to the Build section. Then under Customize, select the object for whom we want to get the date and time value. Here, I choose the Products from the object list.

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

Use DATETIMEVALUE Formula in Salesforce Classic
DATETIMEVALUE Formula in Salesforce Classic

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

Use DATETIMEVALUE Formula in Salesforce Classic Example
DATETIMEVALUE Formula in Salesforce Classic Example

Step 6: Select the Formula as the field type.

Step 7: Click Next to proceed.

DATETIMEVALUE Formula in Salesforce Classic
DATETIMEVALUE Formula in Salesforce Classic

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

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

DATETIMEVALUE Formula in Salesforce Classic Example
DATETIMEVALUE Formula in Salesforce Classic Example

Step 10: Enter the formula to get the date and time value of the field in the advance formula editor. The formula is as follows:

DATETIMEVALUE(Purchase_Date__c)
  • In this formula, we use the DATITIMEVALUE() formula to get the date and time for the given custom date field called “Purchase_Date__c”.

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.

DATETIMEVALUE Advance Formula in Salesforce Classic
DATETIMEVALUE Advance Formula in Salesforce Classic

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.

DATETIMEVALUE Advance Formula in Salesforce Classic Example
DATETIMEVALUE Advance Formula in Salesforce Classic Example

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 DATETIMEVALUE Formula
Salesforce Classic DATETIMEVALUE Formula

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

  • Create a new Product with the field Purchase Date value by opening the products tab and saving it.
  • After that, click on the Details section, and here the Purchase Date and Time field will appear with the date and time value.
Salesforce Classic DATETIMEVALUE Formula Example
Salesforce Classic DATETIMEVALUE Formula Example

In a conclusion, we now understand how to get the date and time value from the expression using Salesforce Classic’s advanced formula.

Also, Read

Conclusion

In conclusion, we have learned the advance salesforce formula to get the Date Time value of the date field.

Moreover, we have learned that both Salesforce Classic and Salesforce Lightning provide a simple procedure to get the date and time value of the date field.

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

  • How to use DATETIMEVALUE Formula in Salesforce Lightning
  • How to use DATETIMEVALUE Formula in Salesforce Classic