Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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 31-Jul-13 20:09pm
Comments
Jameel M at 1-Aug-13 1:10am
   
where you are stuck?
Crixalis Paul at 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 at 1-Aug-13 2:13am
   
Please Help me with this
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Maciej Los at 1-Aug-13 3:57am
   
Yes, yes, yes!
+5!
codejet at 5-Aug-13 10:26am
   
I Agree
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

As Richard MacCutchan has mentioned, you need to use query to calculate age. You don't need to store its value in a database.
SELECT [BirthDate], Date() AS [Today], DateDiff("yyyy", [BirthDate], Date())  AS [Age]
 
More:
MS Access: Date() function[^]
MS Access: DateDiff function[^]
  Permalink  
Comments
Richard MacCutchan at 1-Aug-13 8:47am
   
+5; that's the bit I didn't know.
Maciej Los at 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)

  Print Answers RSS
0 OriginalGriff 7,130
1 DamithSL 5,089
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,647
4 Kornfeld Eliyahu Peter 4,409


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 1 Aug 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100