开发者

add integer to datetime to find out date in vb.net

开发者 https://www.devze.com 2022-12-20 19:06 出处:网络
similiar question to the one asked before by someone, about age and date. I have 2 fields in sql server 2008

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" l开发者_JAVA技巧icence_age = 16 how do i get the year he go his licence from this information?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消