我有以下代码可以从今天的日期计算一个人的出生日期,效果很好
SELECT application.applicationLastName, application.applicationFirstName, application.applicationDoB,
ROUND(DATEDIFF(NOW(), applicationDoB) / 365.2425,1) AS age, application.applicationID, application.applicationAcknowledged, application.applicationContacted, application.applicationDate
FROM application
ORDER BY application.applicationDate ASC
但是,我被要求从本月 1 日开始计算他们的年龄并尝试过
SELECT application.applicationLastName, application.applicationFirstName, application.applicationDoB, DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0) AS CURMONTH,
ROUND(DATEDIFF(CURMONTH(), applicationDoB) / 365.2425,1) AS age, application.applicationID, application.applicationAcknowledged, application.applicationContacted, application.applicationDate
FROM application
ORDER BY application.applicationDate ASC
但是我收到以下错误:调用本机函数'DATEDIFF'中的参数计数不正确