2

I have a node in my file XSLT, i want subtracting n hours.

<xsl:element name="DocDate">
 <xsl:variable name="Date" select="'2013-11-21T11:41:25'"/>
 <xsl:variable name="Date_sub" select="substring($Date,12,19)" /> //Here i bring the hour (11:41:25) 
</xsl:element>

But now i want subtracting n hours for example subtract two hours. I want some like this: Hour = (11:41:25) - (02:00:00) = (09:41:25). Some suggestions? Thanks

Sorry, i´m using XSL 1.0.

AstroCB
  • 12,337
  • 20
  • 57
  • 73
Christian
  • 117
  • 1
  • 12
  • I resolve with this way: http://stackoverflow.com/questions/1575111/can-an-xslt-insert-the-current-date – Christian Nov 21 '13 at 20:23

1 Answers1

0

You can use "date add" function/template from EXSLT (http://exslt.org/date/functions/add/date.add.html).

XSL Template: http://exslt.org/date/functions/add/date.add.template.xsl

Example to add 2h to current date:

<xsl:stylesheet version="1.0" 
    xmlns:date="http://exslt.org/dates-and-times" 
    extension-element-prefixes="date"
    ...>

    <xsl:import href="date.add.template.xsl" />

    ...
    <xsl:call-template name="date:add">
       <xsl:with-param name="date-time"><xsl:value-of select="current-date()" /></xsl:with-param>
       <xsl:with-param name="duration">PT2H</xsl:with-param>
    </xsl:call-template>
</xsl:stylesheet>
Schelldorfer
  • 301
  • 1
  • 4
  • 7