title: XSLT transformation datetime to date format
body: <p>I'm trying to transform a datetime to a date format yyyy-MM-dd, because I'm using the xsd.exe tool the xs:date datatypes are automatically changed into a datetime datatype, because there is no type in the .NET Framework that matches the type xs:date completely.</p>
  
  <p>But I can't get it to work</p>
  
  <pre><code>&lt;articles&gt;
          &lt;article&gt;
            &lt;articleid&gt;48992&lt;/articleid&gt;
            &lt;deliverydateasked&gt;2009-01-29T00:00:00+01:00&lt;/deliverydateasked&gt;
          &lt;/article&gt;
          &lt;article&gt;
            &lt;articleid&gt;48993&lt;/articleid&gt;
            &lt;deliverydateasked&gt;2009-01-30T00:00:00+01:00&lt;/deliverydateasked&gt;
          &lt;/article&gt;
  &lt;/articles&gt;
  </code></pre>
  
  <p>trying to convert the xml to</p>
  
  <pre><code>&lt;articles&gt;
          &lt;article&gt;
            &lt;articleid&gt;48992&lt;/articleid&gt;
            &lt;deliverydateasked&gt;2009-01-29&lt;/deliverydateasked&gt;
          &lt;/article&gt;
          &lt;article&gt;
            &lt;articleid&gt;48993&lt;/articleid&gt;
            &lt;deliverydateasked&gt;2009-01-30&lt;/deliverydateasked&gt;
          &lt;/article&gt;
  &lt;/articles&gt;
  </code></pre>
  
  <p>currently I'm using this XSLT</p>
  
  <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
  &lt;xsl:template match="/"&gt;
      &lt;articles&gt;
          &lt;xsl:apply-templates select="article"&gt;
          &lt;/xsl:apply-templates&gt;
              &lt;/articles&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template name="FormatDate"&gt;
  
      &lt;xsl:param name="DateTime" /&gt;
      &lt;xsl:variable name="date"&gt;
          &lt;xsl:value-of select="substring-before($DateTime,'T')" /&gt;
      &lt;/xsl:variable&gt;
  
      &lt;xsl:if test="string-length($date) != 10"&gt;
          &lt;xsl:value-of select="$DateTime"/&gt;
      &lt;/xsl:if&gt;
      &lt;xsl:if test="string-length($date) = 10"&gt;
          &lt;xsl:value-of select="$date"/&gt;
      &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="article"&gt;
          &lt;xsl:call-template name="FormatDate"&gt;
              &lt;xsl:with-param name="DateTime" select="deliverydateasked"/&gt;
          &lt;/xsl:call-template&gt;    
  &lt;/xsl:template&gt;     
  </code></pre>
  
  <p></p>
  
  <p>Does anyone know a good xslt transformation.</p>
  
  <p>Thanks in advance</p>
  
  <p>The output result of my code is</p>
  
  <pre><code>&lt;articles /&gt; 
  </code></pre>