Salesforce stores all date and time values internally in UTC (Coordinated Universal Time, also known as Greenwich Mean Time). When building Formula Fields, Workflow Field Updates, or Validation Rules that involve date or time calculations, it is important to understand how time zone conversion behaves — because Salesforce does not perform automatic time zone conversion within formula logic. This article provides sample date and time formulas with detailed explanations to help you build accurate date and time calculations in Salesforce.
Here are sample date and time formulas with additional details to help you build your specific formula.
A Date/Time formula to calculate the time since a record was created: NOW() - CreatedDate
Returns a numeric value in the format 99.99XX, depending on the number of decimal places specified.
How it works:
The value to the left of the decimal is the number of days. The value to the right of the decimal represents the portion of a 24-hour period corresponding to the hours and minutes returned by the calculation.
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 local time zone.
How it works:
You need to modify your formula to adjust for the time zone offset. If you are 7 time zones removed from UTC, calculate the decimal value of 7 hours within a 24-hour period:
The resulting formula modification is: TEXT((CreatedDate) - 0.2916)
To review or ask about other date and time formulas, visit the Salesforce Trailblazer Community topic on #Formulas — 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.