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

Re: Date Difference

Subject: Re: Date Difference
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 20 Dec 2005 00:23:51 GMT
date difference xsl
since xslt2 seems to be ok,something like this seems to work (returning
-1 0 or 1 depending whether the dates are greater equal or less) this is
assuming us date format, switch round [1] and [2] for ddmmyyyy.

<xsl:stylesheet
   version="2.0"
   xmlns:x="data:,x"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>


<xsl:function name="x:date">
 <xsl:param name="d1"/>
 <xsl:variable name="s" select="tokenize($d1,'/')"/>
<xsl:value-of
 select="xs:integer($s[3])*10000+xs:integer($s[1])*100+xs:integer($s[2])"/>
</xsl:function>

<xsl:template name="main">
:<xsl:value-of
select="compare(x:date('9/11/2004'),x:date('10/25/2005'))"/>
:<xsl:value-of
select="compare(x:date('10/25/2005'),x:date('9/11/2004'))"/>
:<xsl:value-of
select="compare(x:date('10/25/2005'),x:date('10/25/2005'))"/>
</xsl:template>



</xsl:stylesheet>



$ saxon8 -it main date1.xsl
<?xml version="1.0" encoding="UTF-8"?>
:-1
:1
:0


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.