开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜