Skip to main content

date_diff

The date function used to return the difference between two date or datetime values as a given unit of duration. Takes three arguments, the start date, the end date, and the unit of duration (one of "year", "decade", "century", "quarter", "month", "week", "day", "hour", "minute", "second", or "millisecond").

Returns: integer

Table 1.

Parameter

Type

dateValue1

datetime, date, time, datetimestamp, gyear, gyearmonth

dateValue2

datetime, date, time, datetimestamp, gyear, gyearmonth

units

string



Example

Query

PREFIX : <https://ddw-doccorp.linked.data.world/d/sparql-function-sample-queries/>
PREFIX fn: <http://data.world/function/functions#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT (fn:date_diff("2001-01-01"^^xsd:date, "2001-01-15"^^xsd:date, "day") as ?date_diff)
{
}

Try the query

Table 2. Results

date_diff

14