Re: time difference help
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 readable. 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. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format