我正在尝试检查未来3个月内的人员证明是否到期。我希望无论何时执行它都能正确执行。一个人必须每6个月更新一次认证。
到目前为止,这是我的代码:
SELECT CERT_DATE "Date Of Last Cert Test",
add_months(CERT_DATE, 6)"Date Due"
FROM TESTING.CERTS
;
答案 0 :(得分:1)
试试这个:
SELECT CERT_DATE "Date Of Last Cert Test",
ADD_MONTHS(CERT_DATE, 6) "Date Due"
FROM TESTING.CERTS
WHERE MONTHS_BETWEEN(CURRENT_DATE, CERT_DATE) <= 3
答案 1 :(得分:-1)
SELECT CERT_DATE [DateOfLastCertTest],
DATEADD(MONTH, 6, CERT_DATE) [DateDue]
FROM TESTING.CERTS