[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Date Comparison using ">=" and "<=" doesn't work -

Subject: Re: Date Comparison using ">=" and "<=" doesn't work - WHY!?!?
From: "David N Bertoni/Cambridge/IBM" <david_n_bertoni@xxxxxxxxxx>
Date: Mon, 11 Mar 2002 20:15:52 -0800
xpath date comparison
The arguments for the relational operators <, <=, >, and >= are converted
to numbers before performing the comparison.  Since the string literals
'2/12/02' '2/15/02' are not a valid numbers in XPath, they are converted to
NaN.  NaN has a very "interesting" property when compared to other numbers
(including itself) -- the result is always false.

XPath 1.0 has no notion of collation comparison between strings using these
operators (although that will probably change in XPath 2.0), nor is there a
data type.

An easy way to handle this is to encode dates in such a way that they can
be compared as numbers.  For  your example, as 20020210 and 20020215.  If
you don't have control over your source document, you'll need to do some
fancy string manipulation, or write an extension function which does the
conversion.

Dave



                                                                                                                                                
                      "Gregory Pearson"                                                                                                         
                      <GregP@xxxxxxxxx>                  To:      <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>                                             
                      Sent by:                           cc:      (bcc: David N Bertoni/Cambridge/IBM)                                          
                      owner-xsl-list@xxxxxxxxxxx         Subject:  Date Comparison using ">=" and "<=" doesn't work - WHY!?!?              
                      rrytech.com                                                                                                               
                                                                                                                                                
                                                                                                                                                
                      03/11/2002 03:28 PM                                                                                                       
                      Please respond to xsl-list                                                                                                
                                                                                                                                                
                                                                                                                                                



Hi.

This works:

     Style.XMLDocument.selectNodes
("//xsl:apply-templates/@select")(1).value = "record[Date = '2/12/02']";

This does NOT work:

     Style.XMLDocument.selectNodes
("//xsl:apply-templates/@select")(1).value = "record[Date >= '2/10/02' and
Date <= '2/15/02']";


IS IT NOT POSSIBLE TO USER ">=" AND "<=" FOR DATES?

Thanks!!






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list







 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.