Loading

Add or Subtract Hours from a Date/Time Field Using a Salesforce Formula

Publiceringsdatum: Jun 10, 2026
Beskrivning

The syntax you can use to add/subtract hours from a Date/Time field is detailed below.

In Salesforce formulas, Date/Time fields are stored in GMT (Greenwich Mean Time). To add or subtract a specific number of hours — for example, to convert a timestamp to a local timezone — you can use simple arithmetic on the Date/Time field value. Note that this approach cannot account for Daylight Saving Time (DST) automatically; Apex code is required for DST-aware timezone conversions.

 

Lösning

Formula Syntax for Adding and Subtracting Hours


To add N hours to a Date/Time field: DateTimeField__c + (N/24)
To subtract N hours from a Date/Time field: DateTimeField__c - (N/24)
In these formulas, N represents the number of hours to add or subtract. Since Date/Time fields are stored in GMT, use the timezone offset (e.g., +5.5 for IST, -8 for PST) as the value of N.

## Important Limitations

Date/Time fields in Salesforce are always stored and calculated in GMT. Any timezone conversion using this formula must manually account for the UTC offset. Daylight Saving Time (DST) cannot be handled by a formula alone — if DST-aware conversion is required, use Apex code instead. See: How to use Date, Date/Time & Time Values in Formulas."

 

Example: "For example, to display the creation timestamp of an Opportunity in India Standard Time (IST, UTC+5:30), use: CreatedDate + (5.5/24). To display it in US Pacific Standard Time (PST, UTC-8), use: CreatedDate - (8/24)."

 

Knowledge-artikelnummer

000384478

 
Laddar
Salesforce Help | Article