Power Automate:如何将字符串转换为日期格式。尝试将 excel 从 OneDrive 导入到 SharePoint 列表

Power Automate: How to convert string to date format. Trying to import excel from OneDrive to SharePoint list

我正在尝试使用 Power Automate 将 excel 文件从 OneDrive 导入 SharePoint 列表。除日期列外,所有列都按预期工作。我无法将日期字符串转换为日期格式。请帮忙

我在 Excel 中了解到 Power Automate 的日期问题。似乎这是一个已知的挑战,我自己尝试了博客中的步骤,我可以按预期转换日期。

Go through this blog and you will have an idea how to work with it.

解决方案

根本问题是 Microsoft Power Automate 将日期列读取为文本。 Excel 以序列日期格式存储日期,这意味着像“2019-01-10”这样的日期在 Power Automate 中将被读取为“43475”。

您可以在此处详细了解 excel 如何处理日期: http://www.cpearson.com/excel/datetime.htm.

因此我们需要在 Power Automate 工作流程中使用以下表达式将数字转换为日期

// Format
if(empty(<DATE TO CONVERT>),null,addDays('1899-12-30',int(<DATE TO CONVERT>),'yyyy-MM-dd'))
// Example
if(empty(item()?['Start Date']),null,addDays('1899-12-30',int(item()?['Start Date']),'yyyy-MM-dd'))