Learn more about date or time calculations in Formula Fields, Workflow field updates, and Validation Rules through the following examples.
Here are a couple sample date and time formulas with additional details that will help you build your specific formula.
Common Date/Time Formulas
A Date/Time formula to calculate the time since a record has been created:
NOW() - CreatedDate
Returns a numeric value in the format 99.99XX, depending on the number of decimal places specified.
Here's how it works:
The value to the left of the decimal is intuitively the number of days. The value to the right of the decimal is a representation of the portion of a 24-hour period of the hours and minutes returned by the calculation.
A returned calculation value of 2.25 represents 2 days and 6 hours.
.25 * 1440 (the number of minutes in a 24-hour period) = 360 minutes
360/60 minutes = 6 hours
Important: Be aware of time zone conversion issues.
If you create a formula to display a calculated Date/Time formula value such as:
TEXT(NOW() - CreatedDate)
The value displayed is a UTC value and is likely inaccurate for your time zone.
Here's how it works:
You will want to modify your formula to adjust the time zone value. If you're 7 timezones removed from UTC, calculate the decimal value of 7 hours of a 24-hour period:
7 * 60 minutes = 420 minutes
420/1440 minutes in a 24-hour period = 0.2916
The resulting formula modification would be:
TEXT((CreatedDate) - 0.2916)
To review or ask about other date and time formulas, visit the Trailblazer Community on "#Formulas" such as Last Modified Date more than 24 hours ago.
Build a Formula Field
Using Date, Date/Time, and Time Values in Formulas
Tips for Working with Date and Date/Time Formula Fields
Add or subtract hours from a Date/Time field
Vote and comment on the Salesforce Idea to Enhance Formula Fields with Time Zone Conversion Functions
000385148

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.