Re: date difference problem
Jeni Tennison <[email protected]>
| Newsgroups | gmane.text.xml.xslt.extensions |
|---|---|
| Organization | Jeni Tennison Consulting Ltd |
| Message-ID | <[email protected]> |
Hi Bhushan, > I used the date difference template to get the difference between 2 > dates. I read the whole doc but the template output is not what it > should be. Below is the call template syntax I used. > > <xsl:call-template name="date:difference"> > <xsl:with-param name="start" select="2003-12-31" /> > <xsl:with-param name="end" select="2003-12-04" /> > </xsl:call-template> > > The output should be -P0Y0M27D > > But the output is P27Y You've missed out the quotes around the dates. The values of the select attributes are being evaluated. 2003 - 12 - 31 is 1960, and 2003 - 12 - 4 is 1987. These are interpreted as xs:gYear values, and there's a gap of 27 years between 1960 and 1987. If you add quotes, so that the call is: <xsl:call-template name="date:difference"> <xsl:with-param name="start" select="'2003-12-31'" /> <xsl:with-param name="end" select="'2003-12-04'" /> </xsl:call-template> then the template will give you the difference between the dates 2003-12-31 and 2003-12-04, and return -P27D, as you expect. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/