0

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?

0

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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