473,836 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Current Age from birthday field

5 New Member
I need a box on my form that computes a person's age using their birthday field entered on the same form (and stored in the table). The current age doesn't need to be stored in a table. I just want it to be visible so that I don't have to do the figuring in my head. Suggestions on the expression that would be needed to show the current age?

I am using Access 2003 with Windows XP in English.

Thanks, Tim
Oct 27 '06 #1
10 8407
smitchcoff
3 New Member
Hey, take a look at the datediff function. If you search the help file, something should come up... Maybe something like:

lbl_age = datediff('yyyy' , cboBirthDate, date)

for more info/syntax, check out:
http://www.techonthene t.com/access/functions/date/datediff.php

Hope this helps!

I need a box on my form that computes a person's age using their birthday field entered on the same form (and stored in the table). The current age doesn't need to be stored in a table. I just want it to be visible so that I don't have to do the figuring in my head. Suggestions on the expression that would be needed to show the current age?

I am using Access 2003 with Windows XP in English.

Thanks, Tim
Oct 27 '06 #2
PEB
1,418 Recognized Expert Top Contributor
And also I can say that it's better to check the Access forum this post is largely discussed

:)
Oct 27 '06 #3
radio1
14 New Member
The following works for me (in Access 2002) -- my Date-Of-Birth field is called "dob". This formula prevents "error" strings from appearing in the calculated age field when the dob field hasn't yet been entered or is invalid.

Expand|Select|Wrap|Line Numbers
  1. =IIf(Nz([dob],"")="","",DateDiff("yyyy",[dob],Now())+(Now()<DateSerial(Year(Now()),Month([dob]),Day([dob]))))
  2.  
Hope this helps,

radio1
Oct 27 '06 #4
timgeitz
5 New Member
Radio, thanks for the coding, it worked fine just the way you had it with my fireld change.

Blessings,
timgeitz
Oct 28 '06 #5
radio1
14 New Member
You're welcome.

Please note that there are possibly "bigger/better/stronger/faster" ways of doing it -- I'm still quite new at Access and VBA coding. You just happened to ask the one question in the entire forum that I was apparently qualified to answer!

Cheers,

-radio1
Oct 28 '06 #6
NeoPa
32,584 Recognized Expert Moderator MVP
That's how it works for all of us radio1.
(Excluding MMcCarthy of course who's just a posting machine of all known Access issues - My hat is permanently off ;-) )
Just reply to the ones that we can help on, which is what you did - so ups to you on that.
Oct 28 '06 #7
PEB
1,418 Recognized Expert Top Contributor
Hi,

First the function

IIf(Nz(#23/03/2000#,"")="","" ,"") a test like this gives me an error:
wrong number of arguments for the function nz()

Nz() is used like : nz(#23/03/2000#) or nz("23/03/2000") only with one argument...

But this part of the function isn't important coz it verifies if there is a birthdate introduced... So keep a part...

The rest of the function is:

DateDiff("yyyy" ,"23/03/2000",Now())+(D ateSerial(Year( Now()),Month("2 3/03/2000"),Day("23/03/2000")))

With string values it doesn't give me correct results...

with date values:

the same result...

But the function DateDiff("yyyy" ,"23/03/2000",Now()) gives just the age without monts and days...

But after some verification you can use this one:

=str(Datediff(" yyyy",Cvdate(Fo rmat("23/03/2000","DD/mm/yyyy")),Now())) +"/"str(Datediff(" m",Dateserial(Y ear(Now()),Mont h(Cvdate(Format ("23/03/2000","DD/mm/yyyy"))),Day(Cv date(Format("23/03/2000","DD/mm/yyyy")))),Now() ))+"/" +str(Datediff(" d",Dateserial(Y ear(Now()),Mont h(Now()),Day(Cv date(Format("23/03/2000","DD/mm/yyyy")))),Now() ))

Have a nice evening!

The following works for me (in Access 2002) -- my Date-Of-Birth field is called "dob". This formula prevents "error" strings from appearing in the calculated age field when the dob field hasn't yet been entered or is invalid.

Expand|Select|Wrap|Line Numbers
  1. =IIf(Nz([dob],"")="","",DateDiff("yyyy",[dob],Now())+(Now()<DateSerial(Year(Now()),Month([dob]),Day([dob]))))
  2.  
Hope this helps,

radio1
Oct 28 '06 #8
PEB
1,418 Recognized Expert Top Contributor
radio 1 10x for the idea...

it was a very good way to find a short way to calculate it..

Before there was threads there , where we with mcarthy have created a long calculation functions about this...

And I wasn't able to begin a thread like the previous one....

But it was a very good idea...

:)
Oct 28 '06 #9
NeoPa
32,584 Recognized Expert Moderator MVP
The optional second parameter to the Nz() function specifies the value to return if the first parameter evaluates to Null.

Thus
Expand|Select|Wrap|Line Numbers
  1. Nz([A], [b])
is equivalent to
Expand|Select|Wrap|Line Numbers
  1. IIf(IsNull([A]), [b], [A])
Oct 28 '06 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

51
989
by: Sandra | last post by:
I was given this problem for extra credit and I am just stuck ! BTW - I am not asking for source code and I am not asking anyone to do my homework as I do want to learn .. I just need a hint or two to get moving and I need to know if what I have written so far is leading me in the right direction ~ Ok - The problem is to find out how many people need to be in a room for a 95% chance that someone in that room will match my birthday I...
13
2361
by: Luigi | last post by:
Imagine I have a small, static, personal site (I do, actually: http://kirpi.it/). And imagine that, just below the title of the page, I would like to have a comment, or a news line, or a birthday reminder, a citation, or whatever you like. At the moment you will find a line that reminds about my small child's second birthday, just as an example. My choice is: a) set it manually every day as I wake up, before breakfast, or b) have it set...
1
1898
by: Ben | last post by:
Hi I am currently building a database in Access 97 and have a (quite easy) question. I want to produce a query / report that will bring out all the people in the database that have a birthday in the current month / next month. The idea would be so that just before the beginning of a new month, the user can click a button that will give a report of all customers who have a birthday next month and this will print out. If
1
3398
by: Claude Alain | last post by:
Hello! We are a small non-profit organisation with about 400 members. We have created a database using Access97 which contains tombstone information on our members, including home adresses and birthdates. We would like to produce monthly reports providing us with a list of all members whose birthdate is coming up during any given month in order to send those members a birthday card in a labelled enveloppe. The best we have come up with...
7
15510
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using DateDiff in VB.NET which is only available in C# if you don't mind linking in Microsoft.VisualBasic.dll to your C# application. I wanted to avoid this so set about a pure C# solution which uses a combination of TimeSpan in whole days and the...
6
26329
by: vijayk | last post by:
Hi all, I have a field which has data as YYYYMMDD, and I have to find the age of the person by substracting it from current date. can you please please advice... thanks
5
5224
by: NomoreSpam4Me | last post by:
Hi, i did a search and find the way to get the birthday without the year. My field is yyyy/mm/dd, (birthday). I also have a day field (1 to 31) and a month field. (1 to 12) My problem is: I can get the birthday for one month in particular, but i would like to be able to get birthday for a week that goes over 2 month.
13
3703
kestrel
by: kestrel | last post by:
Sheila and He-Man are twins; Sheila is the OLDER twin. Assume they were born immediately after each other, an infinitesimally small - but nonzero - amount of time apart. During one year in the course of their lives, Sheila celebrates her birthday two days AFTER He-Man does. How is this possible? Bonus: What is the maximum amount of time by which Sheila and He-Man can be apart in their birthday celebrations during the same year? I think...
1
2392
by: stilldancin12 | last post by:
Ok so i have to write an application that asks for the users birthday and replies with they day of the week in which he or she is born on, using the java program. This is what I have so far.It gives me the actual birthday, but not the day of the week. I feel like i am just missing one simple line of text but I can't figure out what it is. Any help would be appriciated! package Ch2Scanner; import java.text.SimpleDateFormat; import...
0
9660
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10582
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10245
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6976
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5645
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5815
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3106
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.