on 03-31-2009 3:24 PM
Hello Experts
In a XSLT mapping program, I hava a filed, ZZOB which is giving some date.
which I need to compare with the current date.
Condition-
ZZOB is greater than current date or ZZOBLIG = NULL
Then go further statements.
how can i campare with the current date?
Please help.
Thanks
Balaprasad
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Hope the below example would help.
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/compare">
<xsl:param name="a" select="1"/>
<xsl:param name="b" select="2"/>
<xsl:choose>
<xsl:when test="$a < $b">a < b</xsl:when>
<xsl:when test="$a > $b">a > b</xsl:when>
<xsl:when test="$a = $b">a = b</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
The above example is with integers, try out the same with current date comparison( taking substring of only date, month and year separately and then compare).
Let me know if it works.
Regards,
Swetha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This example may help:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="currentDate"/>
<xsl:variable name="firstDate" select="concat(substring($currentDate, 1,4),substring($currentDate, 6,2),substring($currentDate, 9,2))"/>
<xsl:template match="/">
<xsl:apply-templates select="//item"/>
</xsl:template>
<xsl:template match="item">
<xsl:variable name="secondDate" select="concat(substring(submissionDeadline, 1,4),substring(submissionDeadline, 6,2),substring(submissionDeadline, 9,2))"/>
<xsl:choose>
<xsl:when test="$firstDate > $secondDate">
<xsl:call-template name="late"/>
</xsl:when>
<xsl:when test="$firstDate < $secondDate">
<xsl:call-template name="ontime"/>
</xsl:when>
<xsl:when test="$firstDate = $secondDate">
<xsl:call-template name="same"/>
</xsl:when>
<xsl:otherwise>Monkeys<br /></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="ontime">
This is on time
</xsl:template>
<xsl:template name="late">
This is late
</xsl:template>
<xsl:template name="same">
This is on time
</xsl:template>
</xsl:stylesheet>
go through this..
http://www.zvon.org/xxl/XSL-Ref/Tutorials/Date-Time/dt1.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.