Subject: Re: [xsl] time difference help From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 17 May 2005 15:59:14 +0100 |
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/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] time difference help, Kent Seegmiller | Thread | [xsl] RE: Correction, Aron Bock |
RE: [xsl] end.tag minimization prob, Aron Bock | Date | [xsl] select an element, Honglei Chen |
Month |