Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I just wanna ask something and also a little code too.


As of now I have the codes that i needed except for one.



My question is How can i update the age in the database using vb.net?


For example if the person Birthdate(MM/dd) = System.Date.Today(MM/dd) then
Age + 1

Something like that, how can i use that in vb.net and access database.
Posted
Comments
Jameel VM 1-Aug-13 1:10am    
where you are stuck?
Crixalis Paul 1-Aug-13 1:22am    
In the calculation of age.
how can i do that? do i need to use update? but how sir?
Crixalis Paul 1-Aug-13 2:13am    
Please Help me with this

Why do you need to? There is absolutely no point in storing this value in the database because it will be incorrect 99% of the time. Store only the birthdate, then when you need to display the age on a view or printed report, calculate it at the time of display from today's date and the DOB from the database.
 
Share this answer
 
Comments
Maciej Los 1-Aug-13 3:57am    
Yes, yes, yes!
+5!
codejet 5-Aug-13 10:26am    
I Agree
As Richard MacCutchan has mentioned, you need to use query to calculate age. You don't need to store its value in a database.
SQL
SELECT [BirthDate], Date() AS [Today], DateDiff("yyyy", [BirthDate], Date())  AS [Age]


More:
MS Access: Date() function[^]
MS Access: DateDiff function[^]
 
Share this answer
 
Comments
Richard MacCutchan 1-Aug-13 8:47am    
+5; that's the bit I didn't know.
Maciej Los 1-Aug-13 8:48am    
Thank you, Richard ;)
Now, your and mine answer is a complete answer ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900