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?

1 Answer 1


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"/>
        sum : <xsl:value-of select="$NodesTotals" />

  2. Sum rows

      <xsl:template name="TotalValue">
        <xsl:param name="Node"/>     
        <xsl:param  name="Sum" select="0"/>      
          <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:call-template name="TotalValue">
                <xsl:with-param name="Node" select="$Node[position()!=1]"/>
                <xsl:with-param name="Sum" select="$Sum + $desimal"/>
          <xsl:otherwise><xsl:value-of select="$Sum"/></xsl:otherwise>    

Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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