# EXSLT - date:difference - Implementer Page

Version: 1 Status: implemented User Page: index.html XML Definition: date.difference.xml Function Package: date.difference.zip #### Function Syntax
    string date:difference(string, string)
#### Template Syntax
    <xsl:call-template name="date:difference">
       <xsl:with-param name="start" select="string" />
       <xsl:with-param name="end" select="string" />
    </xsl:call-template>
The `date:difference` function returns the duration between the first date and the second date. If the first date occurs before the second date, then the result is a positive duration; if it occurs after the second date, the result is a negative duration. The two dates must both be right-truncated date/time strings in one of the formats defined in [XML Schema Part 2: Datatypes]. The date/time with the most specific format (i.e. the least truncation) is converted into the same format as the date with the most specific format (i.e. the most truncation). The permitted formats are as follows, from most specific to least specific: `xs:dateTime` (`CCYY-MM-DDThh:mm:ss`) `xs:date` (`CCYY-MM-DD`) `xs:gYearMonth` (`CCYY-MM`) `xs:gYear` (`CCYY`) If either of the arguments is not in one of these formats, `date:difference` returns the empty string (`''`). The difference between the date/times is returned as a string in the format defined for `xs:duration` in [3.2.6 duration] of [XML Schema Part 2: Datatypes]. If the date/time string with the least specific format is in either `xs:gYearMonth` or `xs:gYear` format, then the number of days, hours, minutes and seconds in the duration string must be equal to zero. (The format of the string will be `PnYnM`.) The number of months specified in the duration must be less than 12. Otherwise, the number of years and months in the duration string must be equal to zero. (The format of the string will be `PnDTnHnMnS`.) The number of seconds specified in the duration string must be less than 60; the number of minutes must be less than 60; the number of hours must be less than 24. An implementation of this extension function in the EXSLT date namespace must conform to the behaviour described in this document. ## Implementations Built-in support for `date:difference` is available in the following XSLT processors:
Processor | Processor Version | Implemented Version
--- | --- | ---
4XSLT, from 4Suite. | 0.12.0a3 | 1
libxslt from Daniel Veillard et al. | 1.0.19 | 1
The following implementations of `date:difference` are available:
Language | Implemented Version | Creator | Date | Download
--- | --- | --- | --- | ---
EXSLT Function | 1 | Jeni Tennison | 2001-05-12 | date.difference.function.xsl
XSLT Template | 1 | Jeni Tennison | 2001-05-12 | date.difference.template.xsl
Javascript | 1 | Chris Bayes | 2001-06-11 | date.js
Msxsl | 1 | Chris Bayes | 2001-06-16 | date.msxsl.xsl
## Change History Submitted: 2001-05-12 Creator: Jeni Tennison(http://www.jenitennison.com/) Returns the difference between two dates as a duration.
Version | Modified | By | Details
--- | --- | --- | ---
1.1 | 2001-06-11 | Jeni Tennison | Added implementations in Javascript, XSLT and EXSLT - Functions.
1.2 | 2001-06-16 | Jeni Tennison | Updated Javascript implementation. Added Microsoft-specific stylesheet.
1.3 | 2002-08-21 | Craig Stewart | Added 4XSLT and libxslt implementation to the list.
1.4 | 2002-11-12 | Craig Stewart | Updated 4XSLT version to 0.12.0a3.

http://www.exslt.org/date/functions/difference/date.difference.html last modified 2002-11-12