Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 18th, 2017, 05:15 AM
Authorized User
 
Join Date: Feb 2017
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Default Dates between day

Hi,

How does XSLT calculate the number of days between these two dates?


Date1: 02-01-2017
Date2: 20-01-2017

Thank you.
 
Old March 18th, 2017, 05:34 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Assuming XSLT 2 or 3 you can construct two xs: date instances and substract them to get a duration, note however that the format to construct and xs: date is YYYY-MM-DD so you need to extract the components from your format first.

Code:
xs:date('2017-01-20') - xs:date('2017-01-02')
gives a xs:dayTimeDuration P18D
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog

Last edited by Martin Honnen; March 18th, 2017 at 06:43 AM..
 
Old March 20th, 2017, 02:11 AM
Authorized User
 
Join Date: Feb 2017
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi, my first date date1 and second date date2

data1: <xsl:value-of select="//n1:Invoice/cac:PaymentMeans/cbc:PaymentDueDate" disable-output-escaping="yes" />

date2: <xsl:value-of select="//n1:Invoice/cbc:IssueDate" disable-output-escaping="yes" />

i want date2-date1= ... day

How will this be spelled? Thank you..

Quote:
Originally Posted by Martin Honnen View Post
Assuming XSLT 2 or 3 you can construct two xs: date instances and substract them to get a duration, note however that the format to construct and xs: date is YYYY-MM-DD so you need to extract the components from your format first.

Code:
xs:date('2017-01-20') - xs:date('2017-01-02')
gives a xs:dayTimeDuration P18D





Similar Threads
Thread Thread Starter Forum Replies Last Post
YTD by day ferretti40 Excel VBA 2 July 1st, 2010 01:06 PM
getting the same day of the week. crabjoe Classic ASP Basics 3 February 27th, 2008 12:45 PM
converting dates: day of week stolte XSLT 2 November 28th, 2007 11:24 AM
how to get the day from a given date pherms Classic ASP Basics 2 April 16th, 2004 05:38 PM
day to day use of XML mano XML 1 November 27th, 2003 01:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.