Click here to Skip to main content
11,790,021 members (43,353 online)
Rate this: bad
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

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 and access database.
Posted 31-Jul-13 19:09pm
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
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.
Maciej Los at 1-Aug-13 3:57am
Yes, yes, yes!
codejet at 5-Aug-13 10:26am
I Agree
Rate this: bad
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]

MS Access: Date() function[^]
MS Access: DateDiff function[^]
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 1,029
1 Maciej Los 790
2 KrunalRohit 686
3 CPallini 606
4 Richard MacCutchan 460

Advertise | Privacy | Mobile
Web04 | 2.8.1509028.1 | Last Updated 1 Aug 2013
Copyright © CodeProject, 1999-2015
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