从dateTime difference中删除额外字符



希望你一切都好。我有一个场景,我必须计算dateTime字段和当前日期之间的差异。我可以计算差值,但只能使用dateTime格式。

我已经使用这个xslt来计算diff b/w天

<xsl:call-template name="timeDifference">
          <xsl:with-param name="date1"
                          select="$PrjOwnerFinishDate_OutputVar.result/ns1:SummaryPlannedFinishDate"/><!--input var-->
          <xsl:with-param name="date2" select="xp20:current-dateTime()"/>
        </xsl:call-template>

<xsl:template name="timeDifference">
    <xsl:param name="date1"/>
    <xsl:param name="date2"/>
    <xsl:value-of select="xsd:dateTime($date1) - xsd:dateTime($date2)"/>
  </xsl:template>

返回差值,但格式为::-P26DT23H51M40S or P5DT8M20S

但是我只想要其中的天数(如上面示例中的-26或5),包括'+'/'-'符号。即Trim 'P''D'之后的所有内容

我该怎么做?

day-from-dateTime()不工作。请你在这方面帮帮我好吗?

的问候RaviKiran

熟悉从持续时间中提取组件所提供的函数(减去两个dateTime值后):http://www.w3.org/TR/xquery-operators/#component-extraction-functions,如http://www.w3.org/TR/xquery-operators/#func-days-from-duration。

最新更新