How to subtract 1 day (calculate day before) in XSLT 2.0?



Could someone please help calculate one day ago from a given date of type xsd:dateTime using XSLT 2.0?


Sample Input:



<?xml version="1.0" encoding="UTF-8"?>
<objects>
<LastRunTime__c>
<Last_Run_Time__c>2015-01-29T19:55:15.846Z</Last_Run_Time__c>
</LastRunTime__c>
</objects>


Sample Output:



<?xml version="1.0" encoding="UTF-8"?>
<objects>
<LastRunTime__c>
<Last_Run_Time__c>2015-01-28T19:55:15.846Z</Last_Run_Time__c>
</LastRunTime__c>
</objects>


I was trying a few things but was not able to get what I want:



<xsl:template match="/">
<xsl:variable name="vToday" select="/*:objects/*:LastRunTime__c/*:Last_Run_Time__c"/>
Today is: <xsl:sequence select="$vToday"/>
1 day ago it was: <xsl:sequence select="$vToday -1*xs:dayTimeDuration('P1D')"/>
</xsl:template>
</xsl:stylesheet>

No comments:

Post a Comment