Click here to Skip to main content
13,057,050 members (43,637 online)
Rate this:
Please Sign up or sign in to vote.
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

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 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
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 1-Aug-13 3:57am
Yes, yes, yes!
codejet 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 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170728.6 | Last Updated 1 Aug 2013
Copyright © CodeProject, 1999-2017
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