title: Power Query/Excel: Error with DateTime.ToText()
body: <p>In Excel 2016 - Query Editor - Advanced Editor.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>let
      SettingsSheet = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
      #"TimeRange" = Table.TransformColumnTypes(SettingsSheet,{{"From", type datetime}, {"To", type datetime}}),
      From = #"TimeRange"[From],
      To = #"TimeRange"[To],
      DateFormatString = "yyyy-MM-dd-THH:mm:ssZ",
      FormattedFrom = DateTime.ToText(#"TimeRange"[From], DateFormatString ),
      FormattedTo = DateTime.ToText(To, DateFormatString ),
      ...
      (Further in the code, I will need to concart formatted datetimes in a URL string.)
  </code></pre>
  
  <p>If I finish with</p>
  
  <pre><code>...
  in
     #"TimeRange"
  </code></pre>
  
  <p>I get a table with DateTimes, as expected.</p>
  
  <p>If I finish with
      ...
      #"testTable" = { From, To, FormattedFrom, FormattedFrom}
      in
         #"testTable"</p>
  
  <p>I get a table displaying
  1 List
  2 List
  3 Error
  4 Error</p>
  
  <p>while I expected
  3 and 4 to be date formatted as <code>DateFormatString</code> suggests.</p>
  
  <p>I have also tried without <code>DateFormatString</code> as in</p>
  
  <pre><code>FormattedFrom = DateTime.ToText(#"TimeRange"[From]),
  </code></pre>
  
  <p>and with <code>DateFormatString = "YYYYMMDD",</code> as shown in example on <a href="https://msdn.microsoft.com/en-us/library/mt253497.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/mt253497.aspx</a>
  But I got the same result.</p>
  
  <p>How am I supposed to format dates ?</p>
  
  <blockquote>
    <p>Edit: Error says: Expression.Error: We cannot convert a value of type
    List to type DateTime. Details:
        Value=List
        Type=Type</p>
  </blockquote>