iregy
iregy

Reputation: 31

add number to date field in vb.net

i have 2 fields in the database (sql server 08) Dob = "05/09/1965" license_age = 16 how do i get the number of years this person hs had licence. so basically dim age1 = current year - (dob - license_age) thanks

-- thanks for the answers. worked perfectly. another question based on this. how do i find out which year he got his license based on the above two fields?

Upvotes: 1

Views: 1082

Answers (1)

Joel Coehoorn
Joel Coehoorn

Reputation: 415735

Dim dob As DateTime = GetDobFromDb()
Dim licAge As Integer = GetLicAgeFromDb()

Dim age1 As TimeSpan = DateTime.Today - dob.AddYears(licAge)

Upvotes: 3

Related Questions