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
2010-02-22 21:56:08
+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
2010-02-22 22:06:36
i want it on vb.net side, not sql
iregy
2010-02-22 22:15:50
Anything else I can help with or does that answer your question?
chrissr
2010-02-22 22:22:23