我正在尝试将列LastUpdated
与 todays 日期(以天为单位)进行比较,四舍五入到小数点后一位。我不断收到错误
ERROR at line 4:
ORA-00904: "DATEDIFF": invalid identifier
有什么想法吗?
SELECT
DISTINCT "AppName",
"ApprovedForRelease",
DATEDIFF(DAY,"LastUpdated",GETDATE()) AS "DaySinceUpdated"
FROM BR_APP
WHERE "ApprovedForRelease" = 'Y';
答案 0 :(得分:2)
在Oracle中,可以使用减法。要获取日期之间的时间,请截断时间:
SELECT DISTINCT "AppName", "ApprovedForRelease",
(TRUNC(sysdate) - TRUNC("LastUpdated")) AS "DaySinceUpdated"
FROM BR_APP
WHERE "ApprovedForRelease" = 'Y';
您使用的代码基于SQL Server。