title: Linq 2 Sql DateTime format to string yyyy-MM-dd
body: <p>Basically, i need the equivalent of T-SQL <code>CONVERT(NVARCHAR(10), datevalue, 126)</code></p>
  
  <p>I've tried:</p>
  
  <ol>
  <li><code>from t in ctx.table
  select t.Date.ToString("yyyy-MM-dd")</code>
  but it throws not supported exception</li>
  <li><code>from t in ctx.table
  select "" + t.Date.Year + "-" + t.Date.Month + "-" + t.Date.Day</code>
  but i don't think it's an usable solution, because i might need to be able to change the format.</li>
  </ol>
  
  <p><strike>The only option I see is to use <code>Convert.ToString(t.Date, FormatProvider)</code>, but i need a format provider, and I'm not sure it works either</strike></p>
  
  <p>FormatProvider doesn't <a href="http://msdn.microsoft.com/en-us/library/bb882655.aspx" rel="noreferrer">work</a>, <a href="http://msdn.microsoft.com/en-us/library/bb882672.aspx" rel="noreferrer">String.Format</a> doesn't work (<code>string.Format("{0:yyyy-MM-dd}", t.Date)</code> throws not supported exception too).</p>