# Time Formula Functions

Like other formula functions, the timeDiff and timeOffset functions use date-related data to perform a calculation or task. These functions do not require multiple values and therefore do not require Relationship or Reference variable types or data from more than one field or formula. Formulas do not calculate automatically on their own.  A formula will re-calculate whenever a variable referenced by the formula changes in value.

# timeDiff

This function returns the difference between two dates using two Date & Time variables or a Date & Time variable and the today function. By default, this function returns the difference between the dates in seconds, however, you can specify that the results are returned in days or hours.

Using the dates May 15, 2018 (variable A) and May 14, 2018 (variable B) as examples, this function could return the following:

 UNIT OF TIME FORMULA RESULT Seconds (default) timeDiff(A,B) 86400 Hours timeDiff(A,B,"hours") 24 Days timeDiff(A,B,"days") 1 Today's date (May 15, 2018), days timeDiff(today(),B,"days") 1

# timeOffset

This function offsets (adds or subtracts) seconds, days, or months from a Date & Time field variable.

Before using this function, note that:

• This function returns results in Unix (epoch) timestamp format (e.g., May 2018 is returned as 1525132800). This output is not converted by Resolver Core and must be done manually.
• Depending on how you intend to use the timeOffset function in a formula, it's possible to display the results in a standard date format by inserting the Unix timestamps into the Max Value field, then creating a label for the timestamp's date equivalent (see screenshot below for an example). Contact Resolver Support for additional information. Configuring a formula's display settings to display Unix timestamps as a standard date format.

Using May 15, 2018 (variable A) as an example, this function could return the following:

 UNIT OF TIME FORMULA RESULT Seconds timeOffset(A,86400,"seconds") 1526495700 (May 16, 2018) Days timeOffset(A,2,"days") 1526582100 (May 17, 2018) Months timeOffset(A,1,"months") 1529087700 (June 15, 2018) Days (subtracted) timeOffset(A,-3,"days") 1526150100 (May 12, 2018)