tags:

views:

1218

answers:

4

I have

<xsl:value-of select="DifferenceInDays" />

DifferenceInDays can be negative or positive, I want to display it as positive. How can I do this?

A: 

Got it, does the trick.

Mithil Deshmukh
What does the trick? Is there an answer here?
Zack Mulgrew
<xsl:value-of select='format-number(DifferenceInDays, "#;#")
Mithil Deshmukh
+1  A: 

This can be achieved using the xpath abs function.

<xsl:value-of select="abs(DifferenceInDays)"/>
Jory
+4  A: 

In XPath 1.0 (XSLT 1.0) use the following expression:

   $vNum*($vNum >=0) - $vNum*($vNum &lt; 0)

In XPath 2.0 (XSLT 2.0) use the abs() function.

Dimitre Novatchev
A: 

diffInDays * (1 - 2*(diffInDays &lt; 0))