Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Date comparison in xslt

From: tokyo12@-----.---
To: 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', (), ()), '&#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