views:

128

answers:

2

similiar question to the one asked before by someone, about age and date. I have 2 fields in sql server 2008 DOB = "01/05/1952" licence_age = 16 how do i get the year he go his licence from this information?

A: 

To do this in the SQL query, checkout the DATEPART function. It and some trivial math should get you what you want.

Matthew Jones
+2  A: 

Assuming you already have DOB in a Date object named "myDate" and license_age in an Integer named "numYears", this will get you the license year:

myDate.AddYears(numYears).Year

Update Since you tagged this VB.NET, I assume you wanted a VB.NET answer. If you want to do this on the SQL side, then the other answer is correct.

chrissr
i want it on vb.net side, not sql
iregy
Anything else I can help with or does that answer your question?
chrissr