[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: time difference help

Subject: Re: time difference help
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 17 May 2005 15:59:14 +0100
xslt time difference
Hi Kent,

> I have two elements:
> <due date>2005-04-05</due date>
> <actual arrival>2005-04-11T22:21:30</actual arrival>
> what is the function to display the day-time difference?

Assuming you're using XSLT 2.0 and that the elements are actually
called <due-date> and <actual-arrival>, you can use the minus operator
as follows:

  xs:dateTime(actual-arrival) - xs:dateTime(xs:date(due-date))

to get the xdt:dayTimeDuration P6DT22H21M30S (6 days, 22 hours, 21
minutes, 30 seconds). You can then use the days-from-duration(),
hours-from-duration() etc. functions to extract the values of the
individual components from that duration in order to make something

Note that the xs:date() constructor constructs an xs:date from the
due date, and the xs:dateTime() constructor casts this to a
xs:dateTime by adding 00:00:00 as the time.



Jeni Tennison

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.