Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Age Expression

Status
Not open for further replies.

Cnnx

Technical User
Aug 19, 2003
16
GB
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:
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)
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?
 
SQL Server syntax is different from VB/.NET

In RS, expressions are written in VB / .NET. GetDate is an SQL function

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Many thanks xlbo.I know it must have seemed like a silly question but you have saved me a lot of time I would have spent trying to use SQL syntax in RS!
Cheers
 
no probs [cheers]

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top