DATE_DIFF

Returns the precise difference between two given times in terms of years, months, weeks, days, hours, minutes, and seconds. It handles differences across time zones, accounts for leap years, considers months with varying days, and presents both the unit and cumulative differences. When the start time is after the end time the result is returned with absolute values.

Syntax 

DATE_DIFF(start_time, end_time)

Usage examples 

Example 1

Formula

DATE_DIFF('2023-11-03T10:00:00-05:00', '2023-11-03T13:30:45-04:00')

Output

1
{
2
"seconds": 9045,
3
"minutes": 150.75,
4
"hours": 2.51,
5
"days": 0.1,
6
"weeks": 0.01,
7
"units": {
8
"years": 0,
9
"months": 0,
10
"weeks": 0,
11
"days": 0,
12
"hours": 2,
13
"minutes": 30,
14
"seconds": 45
15
}
16
}

Example 2

Formula

DATE_DIFF('1992-12-18T15:11:01+0000', '2023-03-02T11:09:01+0000')

Output

1
{
2
"seconds": 953063880,
3
"minutes": 15884398,
4
"hours": 264739.97,
5
"days": 11030.83,
6
"weeks": 1575.83,
7
"units": {
8
"years": 30,
9
"months": 2,
10
"weeks": 1,
11
"days": 4,
12
"hours": 19,
13
"minutes": 58,
14
"seconds": 0
15
}
16
}

Sample Actions 

Transform
DATE_DIFF

Select an action to inspect.

You can also click "Copy action" and paste them in your Tines story to see how they work.

Was this helpful?