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 19: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
Your Filters
Interested
Ignored
     
0 Shai Vashdi 963
1 Tadit Dash 270
2 Sergey Alexandrovich Kryukov 250
3 OriginalGriff 233
4 Peter Leow 180
0 Sergey Alexandrovich Kryukov 9,435
1 OriginalGriff 5,498
2 Peter Leow 4,230
3 Maciej Los 3,540
4 Abhinav S 3,353


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