Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT:IF Date Problem 2

Status
Not open for further replies.

TheVillageIdiot27

Programmer
Nov 10, 2005
58
GB
I am having a problem with a part of of an XSLT. I have an XML file, part of which looks like:

Code:
<tr tr_trdate="2005-09-12T00:00:00"/>
<tr tr_trdate="2006-11-28T00:00:00"/>
<tr tr_trdate="2007-01-01T00:00:00"/>

In the corresponding part of the XSLT I need to filter out the older values (say before 2006-08-01) but I can't seem to get the test to work.

Code:
<xsl:for-each select="tr">
<xsl:if test="?">
<li><xsl:value-of select="@tr_trdate"/></li>
</xsl:if>
</xsl:for-each>

If anyone could help out I would appreciate it loads.

Thanks in advance
 
XSLT has no 'native' date arithmetic support. For your situation, I would think that a bit of tweaking with substrings would do the job. Beyond that, you could add date conversion support through an extension function.

Tom Morrison
 
Compare dates in xslt 1.0 is done by number, or variations of it.
[tt] <xsl:if test="number(translate(substring(@tr_trdate,1,10),'-','')) &gt; 20060801">[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top