We are moving our reporting to SQL server 2005 Reporting Services and need an expression for current age in reports.
Previously using SQL Server 2000 I had a stored procedure which calculated age as:
However when I tried this as an expression in Reporting Services 2005 it didn't work. By trial and error I discovered the following
gave the required result.
Can anyone explain why GETDATE() doesn't work? Presumably when I come to rewrite the stored procedure on SQL Server 2005 I will have to use the same syntax?
Previously using SQL Server 2000 I had a stored procedure which calculated age as:
Code:
(DateDiff(day,DOB, GETDATE()) -0.5)/365.25)
However when I tried this as an expression in Reporting Services 2005 it didn't work. By trial and error I discovered the following
Code:
(DateDiff("d",DOB, TODAY()) -0.5)/365.25)
Can anyone explain why GETDATE() doesn't work? Presumably when I come to rewrite the stored procedure on SQL Server 2005 I will have to use the same syntax?