Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have an issue again...

I create list from csvfile. I convert string with date into DateTime type like this:

 string[] formattedDates = { "dd.MM.yyyy HH:mm:ss", "mm:ss", "HH:mm:ss", "dd.MM.yyyy", "HH:mm:ss" };

 newEntry["Duration"] = DateTime.ParseExact("00:05", formattedDates, CultureInfo.InvariantCulture, DateTimeStyles.None);

but when i check my list of data - duration time (ex: 01:44, 00:05) converts and shows up like this 8/27/2012 00:05 (but it is not Time it is only duration time)

So the questions are:

  1. How make it show up in the list in suitable format (without date = "00:05")?

  2. Will minutes 00:05, 00:41, 01:03 sum as 01:49 - total duration?

  3. If 2. is not possible, can you offer your solution?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

Many thanks to Marc D Anderson( [link] (http://sympmarc.com/2009/05/29/summing-calculated-columns-in-dvwps/)):

  1. call template

    <td class="ms-vh" nowrap="nowrap">                                              
    <xsl:variable name ="NodesTotals">                             
     <xsl:call-template name="TotalValue">
         <xsl:with-param name="Node" select="$nodeset"/>
     </xsl:call-template>                        
    </xsl:variable> 
        sum : <xsl:value-of select="$NodesTotals" />
    

  2. Sum rows

      <xsl:template name="TotalValue">
        <xsl:param name="Node"/>     
        <xsl:param  name="Sum" select="0"/>      
        <xsl:choose>
          <xsl:when test="$Node">
             <xsl:variable name="desimal">
                <xsl:value-of select="substring-before(ddwrt:FormatDateTime(string($Node[1]/@Duration),1033,'HH:mm'),':')*60 + substring-after(ddwrt:FormatDateTime(string($Node[1]/@Duration),1033,'HH:mm'),':')"/>
             </xsl:variable>
             <xsl:call-template name="TotalValue">
                <xsl:with-param name="Node" select="$Node[position()!=1]"/>
                <xsl:with-param name="Sum" select="$Sum + $desimal"/>
             </xsl:call-template>
    
          </xsl:when>   
          <xsl:otherwise><xsl:value-of select="$Sum"/></xsl:otherwise>    
       </xsl:choose>
     </xsl:template>
    

Thank you!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.