In Excel 2016 - Query Editor - Advanced Editor.
Here is my 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.)
If I finish with
...
in
#"TimeRange"
I get a table with DateTimes, as expected.
If I finish with ... #"testTable" = { From, To, FormattedFrom, FormattedFrom} in #"testTable"
I get a table displaying 1 List 2 List 3 Error 4 Error
while I expected
3 and 4 to be date formatted as DateFormatString suggests.
I have also tried without DateFormatString as in
FormattedFrom = DateTime.ToText(#"TimeRange"[From]),
and with DateFormatString = "YYYYMMDD", as shown in example on https://msdn.microsoft.com/en-us/library/mt253497.aspx
But I got the same result.
How am I supposed to format dates ?
Edit: Error says: Expression.Error: We cannot convert a value of type List to type DateTime. Details: Value=List Type=Type