![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Date comparison in xslt >Thread Next - Re: Date comparison in xslt Re: Date comparison in xsltTo: 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', (), ()), ' ')"/> </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/ | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
