Loading

Create a Field or Report which shows Days since 'Last Activity'

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

In Salesforce, the LastActivityDate field is a system field that stores the date of the most recently logged activity (such as a task, event, call, or email) on a record. Standard objects like Leads, Contacts, Opportunities, and Accounts include this field by default when you create a report.

This article explains how to create a custom formula field on a Salesforce object that calculates and displays the number of days since the last activity occurred on that record. The same formula can also be used in reports to filter or sort records by activity recency.

Решение

How to Create a "Days Since Last Activity" Formula Field

Use the following steps to create a Number formula field using the formula TODAY() - LastActivityDate. This formula subtracts the date of the last activity from today's date and returns the number of days elapsed.

In Lightning Experience

  1. Go to Setup | Object Manager | select your object | Fields & Relationships

In Salesforce Classic

  • For Standard Objects: Setup | Build | Customize | [Object Name] | Fields | Custom Fields & Relationships
  • For Custom Objects: Setup | Build | Create | Objects | [Object Name] | Custom Fields & Relationships

Steps to Create the Formula Field

  1. Click New
  2. Select Formula as the field type and click Next
  3. Enter a Field Label (for example: Days Since Last Activity)
  4. Select Number as the formula return type and click Next
  5. In the formula editor, enter: TODAY() - LastActivityDate
  6. Click Next twice, then click Save

Important Considerations

  • Standard objects include the "Last Activity" field by default when creating reports. You do not need to create a custom field to use it in reports.
  • Custom objects only display the Last Activity date when the Allow Activities checkbox is enabled on the object definition.
  • Future activities (tasks or events with a due date in the future) may cause this field to return a negative number.
  • When Shared Activities is enabled for Contacts, the Last Activity date only shows for the Primary Contact on a shared activity.
  • Not all Salesforce objects support the LastActivityDate field. Refer to the Salesforce Object Reference (API Guide) to check if your object supports it.
Дополнительные ресурсы

Salesforce Object Reference — API Guide

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

000387468

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