I am trying to check when a persons certification is due within the next 3 months. I want this to be able to execute correctly no matter when it is executed. A person has to renew their certification every 6 months.

Here is my code so far:

 SELECT CERT_DATE "Date Of Last Cert Test",
  add_months(CERT_DATE, 6)"Date Due"
 FROM TESTING.CERTS
 ;
有帮助吗?

解决方案

Try this:

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

其他提示

SELECT CERT_DATE [DateOfLastCertTest], 
DATEADD(MONTH, 6, CERT_DATE) [DateDue]
FROM TESTING.CERTS
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top