Print this page

How to Add/Subtract hours from a Date/Time Field

Knowledge Article Number 000221466
Description This article provides the syntax you can use when adding or subtracting hours from a Date/Time Field.
Resolution Here is the syntax to add or subtract hours to an existing Date/Time field where N is the number of hours:

Add N hours to a date time field : Datetimefield__c + (N/24)
Subtract N hours to a date time field : Datetimefield__c - (N/24)

This function can also be used when converting a GMT value to another timezone using formula. You can add or subtract the hours depending on the offset. 

****Note that Date/Time fields is always calculated using GMT time zone and any calculation would need to take timezone difference into account. 




promote demote