Loading

Convert Activity CallDurationInSeconds (Decimal) to Hours:Minutes:Seconds (Time) Format

Дата публикации: Oct 9, 2026
Описание

This article explains how to convert a Task's Call Duration (seconds) field into a readable time format (HH:MM:SS) using a custom formula field. For example, there is a field on the Task object that indicates the duration of a call in seconds. This field is populated when a call is answered using Salesforce CRM Call Center. Let's say you have a call lasting 1 minute and 35 seconds; this field will be populated as 95 seconds. This article walks through creating a formula field on the Task object to convert the total seconds into HH:MM:SS format.

Решение

This article answers a common question about the Task object in Salesforce: how do you convert the CallDurationInSeconds field, which stores call length as a raw number of seconds, into a readable HH:MM:SS time format? You do this by creating a custom formula text field on the Task object using the formula provided below.

Open the Activity Object in Object Manager

  1. Navigate to Setup.

    Screenshot of navigating to Setup

  2. Click on Object Manager and then Activity.

    Screenshot of Object Manager with Activity highlighted

  3. Click on Fields & Relationships and New to create the field.

    Screenshot of Fields and Relationships list with New button highlighted

Define the Formula Field Type and Label

  1. Select Formula and click on the Next button.

    Screenshot of Formula field type selection

  2. Type any label in the Field Label field. The Field Name is filled in automatically.

    Screenshot of Field Label entry with auto-filled Field Name

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

    Screenshot of Formula Return Type set to Text

Enter the HH:MM:SS Conversion Formula

  1. Use the formula below and click on the Check Syntax button available at the bottom left of the editor to validate the entered formula.

    IF
    (ISBLANK( CallDurationinSeconds),NULL,
              LPAD(TEXT( FLOOR(CallDurationinSeconds /60 / 60)),2,"0") + ":" +
              LPAD(TEXT(FLOOR( (CallDurationinSeconds)/60) - FLOOR(CallDurationinSeconds /60 / 60)*60),2,"0") + ":" +
              LPAD(TEXT( FLOOR(MOD((CallDurationinSeconds)/60,1)*60)),2,"0")
    )

    This formula works by dividing the total seconds into hours, minutes, and seconds. It first calculates the whole number of hours by dividing seconds by 3600, then finds the remaining minutes and seconds. It pads each value with a leading zero using the LPAD function so the result always displays in a consistent HH:MM:SS format. For example, a call of 95 seconds displays as 00:01:35.

    Screenshot of Check Syntax validation button

Set Blank Field Handling, Field-Level Security, and Page Layouts

  1. In the Blank Field Handling section, select Treat blank fields as blanks and click on the Next button.

    Screenshot of Blank Field Handling section set to Treat blank fields as blanks

  2. Select the appropriate Profiles for the Field Level Security and click on the Next button.

    Screenshot of Field-Level Security profile selection

  3. Select the appropriate Page Layouts and click on the Save button.

    Screenshot of Page Layout selection with Save button

Номер статьи базы знаний

000394751

 
Загрузка
Salesforce Help | Article