Skip to main content

date_sub

The date function used to subtract some period of duration from a date or datetime value. Takes three arguments, the original date, a number of units of duration to subtract, and the unit of duration (one of "year", "decade", "century", "quarter", "month", "week", "day", "hour", "minute", "second", or "millisecond").

Parameter

Type

dateValue

datetime, date, time, datetimestamp, gyear, gyearmonth

quantity

integer

units

string

Returns: date

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_sub("2001-01-01"^^xsd:date, 1, "day") as ?date_sub)
{
}

Run query

Results:

date-sub

2000-12-31