Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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
 
Old March 25th, 2014, 06:21 PM
Authorized User
 
Join Date: Mar 2014
Posts: 26
Thanks: 2
Thanked 0 Times in 0 Posts
Default 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 &lt; $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.
 
Old March 25th, 2014, 07:53 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
 
Old March 26th, 2014, 10:06 AM
Authorized User
 
Join Date: Mar 2014
Posts: 26
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by mhkay View Post
(a) what your data looks like
When I look in the database, I see 2014/03/11.

Quote:
Originally Posted by mhkay View Post
(b) whether you are using XSLT 1.0 or 2.0
1.0
 
Old March 26th, 2014, 12:46 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

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.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old March 26th, 2014, 04:39 PM
Authorized User
 
Join Date: Mar 2014
Posts: 26
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by samjudson View Post
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?
 
Old March 26th, 2014, 04:44 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

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.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
comparing dates help. warhero XSLT 1 July 5th, 2007 09:41 AM
Comparing dates Tomi XSLT 1 September 21st, 2006 04:45 AM
Comparing Dates bennybee JSP Basics 1 April 3rd, 2005 09:31 PM
Help comparing dates Dave Brown Beginning PHP 3 December 20th, 2004 04:03 PM
Comparing Dates Issue tdaustin Classic ASP Basics 2 June 2nd, 2004 06:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.