![]() |
![]() | ![]() | ![]() | 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 11:48:00 PM
Many thanks for your reply. I now got the syntax correct to extract
the date and be able to do a comparison with it.
I am doing this now:
<xsl:value-of select="format-number(sum($prod/quant/
@val),'###,###,###,##0')"/>
I want the sum() only to run on the field called quant on records
where the "todaydate" > June 1. So I tried:
<xsl:value-of select="format-
number(sum($prod[number(translate(todaydate/@val, '-','')) >
number(translate('2007-06-01', '-', '')) ]/quant/
@val),'###,###,###,##0')"/>
Is that totally wrong? It doesnt print anything!
On Jul 9, 10:54 pm, Martin Honnen <mahotr...@yahoo.de> wrote:
> toky...@gmail.com 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 | |||||
|
