VB.NET age calculation in database -
i wanna ask , little code too. of have codes needed except one. question how can update age in database using vb.net? example if bdate has meet todays date his/her age increment one.
if want age column, make computed column, don't have maintain yourself. haven't said database system you're using, i'll assume sql server (other products may have different ways declare such columns, , have different datetime manipulation functions):
create table t ( dateofbirth date not null, age case when dateadd(year,datediff(year,dateofbirth,current_timestamp),dateofbirth) > current_timestamp datediff(year,dateofbirth,current_timestamp)-1 else datediff(year,dateofbirth,current_timestamp) end )
Comments
Post a Comment