Date and time calculations in formula fields
Key Takeaway
The first step in any date formula is knowing which data type you have, because each type gives different results in arithmetic and handles time zones differently.
Formula fields can do math with dates and times, such as counting days until a payment is due, projecting a renewal date, or flagging stale records. Salesforce uses three separate data types for this: Date, Date/Time, and Time.
The three date and time data types
| Data type | What it stores |
|---|---|
| Date | A year, month, and day |
| Date/Time | A date plus a time, precise to the second |
| Time | A time of day with no date, precise to the millisecond, such as a business opening time |
Date/Time and Time values handle time zones differently. Salesforce saves a Date/Time value in GMT and shows it in the viewer's time zone. Salesforce saves a Time value in the saving user's time zone and doesn't convert it for other viewers.
A field's name doesn't reveal its type. Created Date (CreatedDate) and Last Modified Date are Date/Time fields, but Last Activity Date is a Date field.