0

I need a help.

I have a SQL SERVER database where I have put persons with their birthdate. I need to calculate ages of them. For examble my birthdate is 12/27/1982 and I have to debit (minus) from current date.

Does anyone have any idea how to solve this problem.

3
Contributors
5
Replies
6
Views
12 Years
Discussion Span
Last Post by blindmancries
0

Use the SQL DATEDIFF function.

DATEDIFF( datapart, date_expression1, date_expression2)

i.e.

DATEDIFF (year, '1/1/1999', '1/1/2000')   

[b] would give [u]1[/u] as a result [/b]

Hope that helps

Happy coding :cool:

0

Tricky?

And what does Javascript have to do with SQL functions?

The function is simple.... how is it tricky?
:?::?:

Sounds tricky! Maybe you could adapt a javascript to suit your needs?

0

I still get error on calculation, but it is syntax error.

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'year'.

Where could be the problem.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.