Power Query/Excel:DateTime.ToText()错误

Power Query/Excel:DateTime.ToText()错误,excel,business-intelligence,powerquery,Excel,Business Intelligence,Powerquery,在Excel 2016-查询编辑器-高级编辑器中 这是我的密码: let SettingsSheet = Excel.CurrentWorkbook(){[Name="Table2"]}[Content], #"TimeRange" = Table.TransformColumnTypes(SettingsSheet,{{"From", type datetime}, {"To", type datetime}}), From = #"TimeRange"[From],

在Excel 2016-查询编辑器-高级编辑器中

这是我的密码:

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.)
如果我结束了

...
in
   #"TimeRange"
我得到了一张有日期时间的桌子,正如预期的那样

如果我结束了 ... #“testTable”={From,To,FormattedFrom,FormattedFrom} 在里面 #“测试表”

我得到一张桌子 1名单 2名单 3错误 4错误

当我期待的时候 3和4的日期格式为
DateFormatString

我也尝试过不使用
DateFormatString
,如中所示

FormattedFrom = DateTime.ToText(#"TimeRange"[From]),
并使用
DateFormatString=“yyyyymmdd”
,如上的示例所示 但我得到了同样的结果

我该如何安排日期

编辑:错误为:表达式。错误:无法转换类型为的值 列表以键入日期时间。细节: 值=列表 类型=类型


DateTime.FromText要求将单元格作为第一个参数,而不是列

此添加的自定义列将创建一个文本字符串,将两个日期以所需格式连接起来,并以“-”作为分隔符:

   String = Table.AddColumn(#"TimeRange", "String", each DateTime.ToText([From], DateFormatString)&"-"&DateTime.ToText([To], DateFormatString))

通过右键单击单元格中的“错误”,错误消息将显示在预览窗口中。将其复制到线程中通常也很有帮助。它说“Expression.SyntaxError:Token Equal expected.”在“Table.AddColumn”(“)之后。另外,我真的需要在字符串变量中使用它,我的意思是我需要构建一个URL,以便在以后调用数据服务。我是这样获得该字符串的吗,然后MyString=#“TimeRange”[string](我对这种语言一点也不熟悉。)请检查以下代码:让SettingsSheet=Excel.CurrentWorkbook(){[Name=“Table2”]}[Content],#“TimeRange”=Table.TransformColumnTypes(SettingsSheet,{“From”,type datetime},{“To”,type datetime}}),DateFormatString=“yyyy MM dd THH:MM:ssZ”,String=Table.AddColumn(#“TimeRange”,“String”,每个DateTime.ToText([From],DateFormatString)&“-”和DateTime.ToText([To],DateFormatString])如果您想了解更多关于这种语言的信息,请从以下内容开始:以及周围的文章,并在此处查看更多内容:我现在又向前迈出了一步。现在的问题是,当我写“url=”“&FormattedFrom[FromDate]&“&To=”&FormattedTo[ToDate]时,Source=OData.Feed(url),“我得到”表达式。错误:我们无法将运算符&应用于文本和列表类型。详细信息:运算符=&“Left=[url左侧]Right=List”分号似乎不属于这里:“url=”myurl/something/?from=“;”&相反:“url=”myurl/something/?from=“&…除此之外,您现在应该没事了吧?