我正在尝试将 MS Access 查询转换为 SQL Server,但我无法找出以下代码的 SQL Server 等效项:
First(IIf(DateDiff("yyyy",[DateOfBirth],"31-Aug-2012")+Int(Format("31-Aug-2012","mmdd")<Format([DateOfBirth],"mmdd"))<18,'Parent/Guardian of:',Null)) AS PG,
First(IIf(DateDiff("yyyy",[DateOfBirth],Now())+Int(Format(Now(),"mmdd")<Format([DateOfBirth],"mmdd"))<18,'Parent/Guardian of:',Null)) AS PG_old,
这是我未完成的尝试:
First(CASE WHEN (DateDiff("yyyy",[DateOfBirth],"31-Aug-2012")+Int((DATEPART(mm,(CONVERT(DATE,"31-Aug-2012",103))) + (DATEPART(dd,(CONVERT(DATE,"31-Aug-2012",103)))))<Format([DateOfBirth],"mmdd")) < 18 THEN 'Parent/Guardian of:'
ELSE Null)END) AS PG,