【发布时间】:2021-05-19 02:08:56
【问题描述】:
Select-Object -Property Distributor,'File Date','Report Date',Country,'Customer Name)
我正在使用上面的 Select-Object 命令从 Excel 工作表中选择数据。当我尝试使用 Write-SQLTableData
将 excel 写入 SQL Server 时,第三列 'Report Date' 出现以下错误The given value of type double from the data source cannot be converted to type data of the specified data column.
如何在 Select-Object 命令中应用格式/转换?
【问题讨论】:
-
您的日期格式如何?报告日期的值是多少?
-
如果不显示
double值,您可以尝试使用$date = [datetime]::FromOADate($theDouble)进行转换 -
@guiwhatsthat 在 Excel 中就像 16.02.2021
-
16.02.2021是 Excel 显示,但您在'Report Date'中获得的基础 value 显然是[double]作为错误消息显示。请回答@guiwhatsthat 的问题,以便我们查看报告日期实际包含的内容
标签: sql-server powershell type-conversion