Salesforce MINUTE Function

In this Salesforce tutorial, we will learn about the Minute() function, a versatile tool that plays a crucial role in time-based calculations within Salesforce. This function is executable in Salesforce Lighting and Classic editions.

What is Minute() function in Salesforce

In Salesforce, the Minute() function is a time function used in formulas to extract the minute component from a given time field. The Minute() function helps us in obtaining the minute portion of a time field.

The Minute() function extracts the minute from the time field and the output is returned in the form of numbers from 0 to 60.

For example, if we have used a time field as an expression in the Minute() function. When the time field displays the time as 6:45 pm the Minute() function will extract the minutes and give output as 45:00.

Syntax for Minute() function

The below Syntax is used to execute the Minute() function in formulas.

Minute(expresssion)

Where the expression will be replaced by the time field. Any field other than the time field will return a syntax error.

Considerations:

There are a few considerations that we should be aware of while using the Minute() function in custom fields or reports in Salesforce.

  • The Minute() function is used with Time fields, make sure you are using a field with Time fields in the expression (syntax) of the Minute() function otherwise, it will give a syntax error.
  • The output of the Minute() function will be generated according to Coordinated Universal Time (UTC). If you are not getting the results according to your system time then consider adjusting time zones, and the results accordingly.

How to use the Minute() function in Salesforce Lightning

In this example, we will use the Minute() function in a Custom formula field and now we will discuss the step-by-step implementation of the Minute() function to the fields in Salesforce Lightning.

1. Navigate to the Setup page of the lightning, and for that click on the settings icon, and from the options in the dropdown select Setup.

Salesforce Lightning Minute function

2. On the Setup page of Salesforce Lightning, click on the Object Manager tab.

Use Minute function in Salesforce Lightning

3. In the Object Manager select an object in which you have to create a formula field using the Minute() function.

In this example, I have selected the object Opportunity.

Execute Minute function to fields in Salesforce

4. In the setup of the selected object, click on the Fields & Relationships in the left sidebar.

In the Fields & Relationship window, click on the New button.

Salesforce Lightning Use Minute function in Custom fields

5. In this step of creating a custom field, select the Formula data type for the custom field and click on the Next button.

Create a Formula Field using Minute function in Salesforce

6. In this step, enter the Field Label for the output field of the formula. In this example, I have entered the field label as Minute duration, and as we click on Field Name, it will be auto-filled according to the entered Field Label.

In the Formula Return Type section, select the number type for the output.

For this formula field, we are using the Minute() function so the output will be a number. For example, If the time is 7:30 AM the output will be 30.

After selecting the Number option click on the Next button.

Salesforce Lightning Execute minute function in a field

7. In this step, enter the formula in the formula editor using the Minute() function.

To insert the Minute() function go to the function scroll bar on the right side of the window and select the MINUTE function then click on the button Insert this field.

Salesforce Lightning Minute function Use case

8. After inserting the Minute() function, we have to insert a field in the expression of the function, and for that click on the button

Add field to the Minute function in Salesforce Lightning

9. As we click on the button Insert Field, we will get a list of all the fields available in the object.

Since the opportunity object doesn’t have a standard Time field, I have created and selected a custom time field Opportunity Time to use as an expression in the Minute() function.

After selecting the time field click on the Insert button.

Insert field to Minute function in Salesforce Lightning

10. After adding the time field in the expression of the Time() function, click on the button Check Syntax and if there is no syntax error in the formula then click on the Next button.

Check Syntax For Minute Function In Salesforce

11. In this step, we have to establish the field-level security for the custom formula field, and to do that we have to select profiles to which we want to give access for this field.

We can select the specific profiles for the field access else activate the Visible checkbox to select all user profiles and after this click on the Next button.

Use Case for Minute Function in Salesforce Lightning

12. In this window, select the page layouts that should include this field. The field will appear only in those page layouts that you have selected.

After selecting the page layouts click on the Save button.

Custom Formula Field with Minute Function in Salesforce Lightning

As we click on the Save button, the custom formula field will be saved in the object that you have selected above.

When you open a record page of the Object you will get the output of extracted minutes in the created formula field.

In this example, I have created the formula field in the Opportunity object and the output field of the minute function is labeled as Minute duration.

Minute function Output in Salesforce Lightning

As we can see in the above image, the formula field Minute Duration displays the minutes from the time field Opportunity Duration that we used as an expression in the Minute function.

In this way, we have successfully executed the Minute() function using a formula field in Salesforce Lightning.

How to use the Minute() function in Salesforce Classic

In the below steps, we will discuss a use case of the Minute() function in Salesforce Classic, where we will create a custom formula field using the Minute() function.

1. On the Home page of Salesforce Classic, click on the Setup tab.

Salesforce Classic Minute function

2. In the Setup page of Classic, go to the left sidebar and click on the Customize dropdown.

From the dropdown select the object in which you have created a formula field using the Minute function and for that select Object -> fields.

In this example, I have selected the object Contacts.

Create a custom Formula Field using Minute function in Salesforce

3. In the Fields setup of an object, scroll down to the section Custom Fields & Relationships and click on the New button.

Minute function use case in Salesforce Classic

4. In this step, select the Formula data type for the custom field and click on the Next button.

Create a Formula Field using Minute function in Salesforce Classic

5. In this step, we will define the output of the formula field.

First, enter the Field Label for the output field. In this example, I have entered Field Label as Contact Minute. The Field Name will be auto-filled according to the entered Field Label.

Select the Formula Return Type as Number and click on the Next button.

Salesforce Classic Minute function execution

6. Now we will enter the formula in the formula editor and for that go to the Functions scroll bar on the right-hand side and select the MINUTE function then click on the button Insert Selected Function.

Custom Formula Field with Minute Function in Salesforce Classic

7. In the formula editor we can see the syntax of the Minute() function as :

MINUTE(expression)

Now we will replace this expression with a time field and for that click on the Insert Field button.

Minute function formula in Salesforce

8. As we click on the Insert Field button, we can see a list of fields that are available in the object.

We have to select a time field for the expression. In this example, I have selected a custom time field Contact Activation. After selecting the field, click on the Insert button.

We can only select a time field in the Minute() function otherwise the formula will return a syntax error.

Salesforce Classic Minute function execution in Custom field

9. After entering the time field in the expression of the Minute() function, click on the Check Syntax button to validate the formula.

On successful validation, click on the Next button.

Salesforce Minute function execution in Classic

10. In this step, we have to establish the field-level security for the formula field.

Select the profiles to which you have to give access for this field else activate the Visible checkbox to give field access to all user profiles and then click on the Next button.

Salesforce Classic Minute function use case

11. Activate the Page layouts to make this field visible in the page layouts. This field will not be visible in the page layouts that are not selected.

After selecting the page layouts for the field click on the Save button.

Salesforce Classic Minute function in Formula field

As we click on the Save button, the custom formula field will be saved in the object that you have selected above.

We can see this custom formula field on the record page of the object in which we have created this field with the Minute() function. The formula field will display the minutes from the field that we have selected as an expression in the formula above.

In this example, I have created the formula field in the Contact object and the output field of the minute function is labeled as Contact Minute.

Minute function output field in Salesforce Classic

In the above image, we can see that the field Contact Minute that we created using the Minute() function extracts the minutes from the time field Contact Activation that we have used as an expression in the formula field.

In this way, we have successfully executed the Minute() function using a custom formula field in Salesforce Classic.

Conclusion

In this Salesforce tutorial, we have learned about the use cases of the Minute() function with the help of custom formula fields in Salesforce Lightning and Salesforce Classic respectively.

Along with this we also discussed the uses, syntax, and considerations that we must be aware of while executing the Minute() function in the formula of fields and reports in Salesforce.

You may like to read: