xsl-list
[Top] [All Lists]

Re: Date Difference

2005-12-19 17:23:51

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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>