Skip to main content

dateDiff (Function)

Returns difference between two dates in days.

Syntax

<INT> time:dateDiff(<STRING> date.value1, <STRING> date.value2, <STRING> date.format1, <STRING> date.format2)
<INT> time:dateDiff(<STRING> date.value1, <STRING> date.value2)
<INT> time:dateDiff(<LONG> timestamp.in.milliseconds1, <LONG> timestamp.in.milliseconds2)

Query Parameters

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
date.value1The value of the first date parameter. For example, 2014-11-11 13:23:44.657, 2014-11-11, 13:23:44.657.-STRINGYesYes
date.value2The value of the second date parameter. For example, 2014-11-11 13:23:44.657, 2014-11-11 , 13:23:44.657.-STRINGYesYes
date.format1The format of the first date value provided. For example, yyyy-MM-dd HH:mm:ss.SSS.`yyyy-MM-dd HH:mm:ss.SSS`STRINGYesYes
date.format2The format of the second date value provided. For example, yyyy-MM-dd HH:mm:ss.SSS.`yyyy-MM-dd HH:mm:ss.SSS`STRINGYesYes
timestamp.in.milliseconds1The first date value in milliseconds from the epoch. For example, 1415712224000L.-LONGYesYes
timestamp.in.milliseconds2The second date value in milliseconds from the epoch. For example, 1415712224000L.-LONGYesYes

Example 1

time:dateDiff('2014-11-11 13:23:44', '2014-11-9 13:23:44', 'yyyy-MM-dd HH:mm:ss', 'yyyy-MM-dd HH:mm:ss')

Returns the date difference between the two given dates as 2.

Example 2

time:dateDiff('2014-11-13 13:23:44', '2014-11-9 13:23:44')

Returns the date difference between the two given dates as 4.

Example 3

time:dateDiff(1415692424000L, 1412841224000L)

Returns the date difference between the two given dates as 33.