How to Create Date Time Field Type in Salesforce

In Salesforce, the date and time are entered using the date and field type, and we can also pick up the date and time from a pop-up calendar.

Now, let’s move further and see how to create the date time field type in Salesforce. The date/time field is available for Salesforce Lightning and Classic editions.

Let’s consider a scenario where Salesforce support team members are assigned cases to resolve. We need to track the date and time when the case is assigned to the user. In this situation, we can create a date-time field that will display the date and time when the case is assigned to the user.

Read How to Create Date Field Type in Salesforce

Create a Date time field in Salesforce

To create a custom date-time field in Salesforce, navigate to the setup page and follow the below steps.

1. On the Setup page, click on the Object Manager tab.

2. In the Object Manager tab, select the object for which you need to create the date-time field. In this example, I selected the Case object.

Salesforce date time field

3. In the Case setup, select Fields & Relationships and click the New button in the next window.

Create a Date time field in Salesforce

4. In the list of Data types, select the Date/time fields and click the Next button.

Date time field in Salesforce lightning

5. Enter the Field Label for the date-time field, and the Field Name will be auto-filled according to the label. We can also make this field mandatory from the Required checkbox if a user enters it manually.

To set the Default Value for the date-time field, we can enter a default date or add a formula from the formula editor.

I have added a formula DATETIMEVALUE(TODAY()) to this date-time field. This formula will populate the field with the current date and time when the case record is created.

At last, click the Next button.

Set default value in Salesforce date time

6. To set the field-level security, select the profiles that can access this date-time field. Then, click on the Next button.

Salesforce created date time field

7. In this step, select the Page layouts that should include this date time field. This field will not appear on any of the layouts if you do not select a layout.

At last, click on the Save button.

Add date time field to page layouts in Salesforce

Now, we have created the date-time field, and in the further steps we will check if it assigned on the record pages with the default value or not.

8. Navigate to the Cases tab and create a New Case.

9. In the case fields, you will see that the date time field is auto-populated according to the current date time using the formula we used for the Default value.

Salesforce default date time field in lightning

This way, we can create a Date-time field in Salesforce by following the above steps.

Read How to Create Currency Field Type in Salesforce

Conclusion

In Salesforce, the date time field displays the date and time in one field. It helps to track the date/time-related information of the records. In this Salesforce tutorial, we have learned to create a custom date-time field with the help of the above steps. Along with this, we have also learned to set a default value for the Salesforce Date time field.

You may 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.