Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Date comparison in xslt

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 7/9/2007 3:55:00 PM

tokyo12@g... wrote:

> So basically what I need to do is make sure my variable is in that
> format or force it to be in that format using some date conversion
> functions.

With XSLT/XPath 1.0 all you can compare with > and < are numbers so you 
need to do
   number(translate('2007-07-09', '-', '')) > 
number(translate('2007-07-08', '-', ''))
that way you compare the numbers 20070709 and 20070708.

> I found some functions to do that like format-dateTime but I couldnt
> get them to work - they dont print anything.  Do they require a "xs:"
> constuct or something else that specifies the namespace where the
> function is to be found?

format-date and format-dateTime are part of XSLT 2.0. Only Saxon and 
Altova so far have products implementing XSLT 2.0. And format-date and 
format-dateTime are not for comparing numbers, they are there to format 
date respectively dateTime values for output. So doing e.g.

     <xsl:for-each select="('2007-07-01', '2000-01-01')">
       <xsl:value-of select="(format-date(xs:date(.) , '[MNn] [D], [Y]', 
'en', (), ()), '&#10;')"/>
     </xsl:for-each>

outputs

July 1, 2007
January 1, 2000

with an XSLT 2.0 processor like Saxon.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent