xsl-list
[Top] [All Lists]

Re: time difference help

2005-05-17 07:59:14
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/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>