Solved

Convert a number to timespan in XSL

Posted on 2006-07-19
3
835 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
Comment Utility
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
Comment Utility
in case you need this line:  <xsl:value-of select="concat('PT', (text()*24), 'H0M0S')" />
0
 
LVL 1

Author Comment

by:dentyne
Comment Utility
Hi Owen,

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Access VBA, Concatenate repeated XML elements 5 78
Fetch XML Unions? 3 357
VB.NET and XML parsing 6 54
Viewing XML as a table on a Mac 3 61
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now