我试图将datetime转换为日期以摆脱时间,但查询结果仍显示时间。当我与看到的online进行比较时,它看起来是正确的。
我该如何解决?
..
, CAST("Process"."StartDate" AS date)
..
结果仍然显示如下:
4/14/2019 0:00
更新:我试图按照下面的建议使用convert,但是我收到了带有“ 1”自变量的异常调用“ fill”。
我的转换语法可能有问题。有任何想法吗?我看到的所有在线示例都将datetime与convert一起使用。 Powershell中的完整查询如下所示:
$SQLquery_Proc = @"
SELECT DISTINCT
Process.Process_ID
,"Process"."ProcessName"
,ProcessFacilities = STUFF(
(SELECT ',' + apf.FacCode FROM ProcessFacilities apf where apf.Process_ID = "Process"."Process_ID" FOR XML PATH ('')), 1, 1, ''
)
, "People"."Last_Name"
, "People"."First_Name"
, "People"."Middle_Initial"
, "People"."Degree"
, "Process"."P_ID"
, "People_Facilities_ALL"."FacCode" as "People_FacCode"
, "People_Facilities_ALL"."Current_status"
, "People_Facilities_ALL"."Status_category"
, convert("People_Facilities_ALL"."Status_from_date", 101) --issue?
, convert("People_Facilities_ALL"."Next_r_date", 101) --issue?
FROM
Process
left JOIN "DB"."dbo"."People" ON "Process"."PRACT_ID"="People"."P_ID"
left JOIN "DB"."dbo"."People_Facilities_ALL" ON "Process"."P_ID"="People_Facilities_ALL"."PRACT_ID"
ORDER BY
"People"."P_ID"
"@
Update2: 我想出了如何使工作转化为工作的方法。感谢您的帮助!
, convert(VARCHAR(23),"People_Facilities_ALL"."Status_from_date", 101)