 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 25th, 2014, 06:21 PM
|
|
Authorized User
|
|
Join Date: Mar 2014
Posts: 26
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Comparing dates
Hello,
I'm trying to do a date comparison in a database query. It looks like this:
<xsl:variable name="dispNotDate" select="PCR/VW_TR_TIMES[@LEVEL3ID=1061]/@EVENTDATE"/>
<xsl:variable name="treatMedList" select="PCR/VW_AP_SUMMARY[@STARTDATE < $dispNotDate]"/>
The query returns nothing to the list though. I know there are entries that meet the above condition, so it shouldn't be returning nothing. My hunch is that one can't compare dates the way I'm doing (i.e. @STARTDATE < $disNotDate).
Can someone guide me please? Thanks.
|
|

March 25th, 2014, 07:53 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
We will need to know
(a) what your data looks like
(b) whether you are using XSLT 1.0 or 2.0
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

March 26th, 2014, 10:06 AM
|
|
Authorized User
|
|
Join Date: Mar 2014
Posts: 26
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by mhkay
(a) what your data looks like
|
When I look in the database, I see 2014/03/11.
Quote:
Originally Posted by mhkay
(b) whether you are using XSLT 1.0 or 2.0
|
1.0
|
|

March 26th, 2014, 12:46 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
But the code above isn't a database query, its XSLT code, which processes XML data. What does your XML data look like?
Basically, if you are in XSLT 1.0 and you want to compare things you can either compare things as numbers, or compare them as strings. XSLT 1.0 does not handle other data types.
|
|

March 26th, 2014, 04:39 PM
|
|
Authorized User
|
|
Join Date: Mar 2014
Posts: 26
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by samjudson
Basically, if you are in XSLT 1.0 and you want to compare things you can either compare things as numbers, or compare them as strings. XSLT 1.0 does not handle other data types.
|
In that case, my best bet would probably be to write a scripted function. Would you agree?
|
|

March 26th, 2014, 04:44 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
If your dates are of the format "YYYY/MM/DD" as a string then you can sort them as a string and they would be in date order as well as alphanumeric order.
This makes me think that one of the fields you talk about above is not in this format, or your XSLT is incorrect. But without seeing the input XML, and what you are expecting to see as your output it is hard to say.
|
|
 |