cancel
Showing results for 
Search instead for 
Did you mean: 

How to Compare date with Current system date in XSLT mapping.

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member620725
Discoverer
0 Kudos

Thank you!

Former Member
0 Kudos

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 &lt; $b">a &lt; b</xsl:when>

<xsl:when test="$a &gt; $b">a &gt; 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.

Former Member
0 Kudos
Former Member
0 Kudos

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 &gt; $secondDate">

<xsl:call-template name="late"/>

</xsl:when>

<xsl:when test="$firstDate &lt; $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>

Former Member
0 Kudos