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 July 5th, 2007, 08:32 AM
Registered User
 
Join Date: Jul 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default comparing dates help.

I've been looking around for a way to compare dates. And it sounded like xslt can.

I'm trying like this:

<xsl:param name="date" />
<xsl:for-each select="dates/date">
<xsl:variable name="firstDate" select="concat(substring($date, 1,4),substring($date, 6,2),substring($date,9,2))"/>
<xsl:variable name="secondDate" select="concat(substring(., 1,4),substring(., 6,2),substring(.,9,2))"/>
<xsl:if test="$secondDate > $firstDate">
 someing
</xsl:if>
</xsl:for-each>

Doesn't seem to be working. Is this the right attempt?

 
Old July 5th, 2007, 09:41 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Can't see anything obviously wrong with your code. Debug it by using xsl:message to display firstDate and secondDate.

In XSLT 2.0 you can compare dates directly, xs:date($x) > xs:date($y)

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing dates Tomi XSLT 1 September 21st, 2006 04:45 AM
Comparing Dates in XSLT kwilliams XSLT 7 December 1st, 2005 08:49 PM
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.