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.
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
|Today's date (May 15, 2018), days||timeDiff(today(),B,"days")||1|
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. To convert your timestamp into standard time or vice versa, see the Convert Unix Time website. To calculate the difference between two dates by seconds, days, or months, see the Unix Time Converter.
- 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.
Using May 15, 2018 (variable A) as an example, this function could return the following:
UNIT OF TIME
|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)|