Solved

Convert a number to timespan in XSL

Posted on 2006-07-19
3
841 Views
Last Modified: 2010-05-18
Hello,

I am receiving an XML data island from a web application that I then convert to Microsoft Project XML via an xsl stylesheet I am creating.  One of the tags called "Duration" that the Microsoft Project requires is of type "timespan".  An acceptable entry for this is:

<Duration>PT80H0M0S</Duration>

Which I think corresponds to 10 days.  (At least that what my duration value is in MSProject.)

But anyway, in the data island I am receiving has the duration as just an integer, like 10,15, 20, etc in days.  How can I convert it to this type of format in my xsl sheet?  I don't really know what PT80H0M0S means.  

Thanks.
0
Comment
Question by:dentyne
  • 2
3 Comments
 
LVL 9

Expert Comment

by:owenli27
ID: 17141631
I believe that Timespan is NET Framework type.
PT80H0M0S means 80 hours and 0 min and 0 secods.  The second char 'T' means TIME.

A example:
P2Y3M18DT10H0M20S is 2 years, 3 months, 18 days, 10 hours, 0 minutes, and 20 seconds.

if you get your "Duration" days as integer, it is very easy to convert it to Hours by times 24 and concatenate it with rest of string. Do you need XSL code for this?
0
 
LVL 9

Accepted Solution

by:
owenli27 earned 500 total points
ID: 17141768
in case you need this line:  <xsl:value-of select="concat('PT', (text()*24), 'H0M0S')" />
0
 
LVL 1

Author Comment

by:dentyne
ID: 17146442
Hi Owen,

Thanks for the help.  I think this will do the trick.  
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question