# EXSLT - date:difference

Implementer Page: date.difference.html 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. ## Implementations The following XSLT processors support `date:difference`: 4XSLT, from 4Suite. (version 0.12.0a3) libxslt from Daniel Veillard et al. (version 1.0.19) Implementations of `date:difference` are available in the following languages: EXSLT Function (by Jeni Tennison) XSLT Template (by Jeni Tennison) Javascript (by Chris Bayes) Msxsl (by Chris Bayes)

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