Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 18th, 2017, 05:15 AM
Authorized User
Points: 60, Level: 1
Points: 60, Level: 1 Points: 60, Level: 1 Points: 60, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2017
Posts: 16
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.
Reply With Quote
  #2 (permalink)  
Old March 18th, 2017, 05:34 AM
Friend of Wrox
Points: 6,522, Level: 34
Points: 6,522, Level: 34 Points: 6,522, Level: 34 Points: 6,522, Level: 34
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,220
Thanks: 0
Thanked 237 Times in 236 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.
Reply With Quote
  #3 (permalink)  
Old March 20th, 2017, 02:11 AM
Authorized User
Points: 60, Level: 1
Points: 60, Level: 1 Points: 60, Level: 1 Points: 60, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2017
Posts: 16
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 11:45 AM
converting dates: day of week stolte XSLT 2 November 28th, 2007 10: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 12:39 AM



All times are GMT -4. The time now is 04:50 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.