Hello, all. I am working on a membership database for our church and have run in to a problem. I need a formula that calculates an age, and I have found that information and can make it work, but how can I add “number of months” if a child is not yet 1 year old? I have all the information currently in an Excel spreadsheet and it works there like a charm. This is the formula used in Excel. =IF(DATEDIF(J130,TODAY(),”y”)>0,DATEDIF(J130,TODAY(),”y”),DATEDIF(J130,TODAY(),”m”)&” Months”) For instance, if a child is born on 12/21/11, it would show “10 months” for that child’s age. I have attached an Excel spreadsheet that shows how it is done there and how I would like it to be in Access. Does anyone have an idea of how I can do this in Access?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Calculate an age, adding # of months if child is not yet 1 year old
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Calculate an age, adding # of months if child is not yet 1 year old
- This topic has 14 replies, 6 voices, and was last updated 12 years, 5 months ago.
AuthorTopicWS79schultz
AskWoody LoungerNovember 5, 2012 at 3:16 pm #486192Viewing 12 reply threadsAuthorReplies-
WSpatt
AskWoody Lounger -
WS79schultz
AskWoody LoungerNovember 7, 2012 at 9:13 am #1355346I’m sorry, that didn’t work. I tried IIf(datediff…..) and I think it was that one that calculated years OK, but I never could get it to show “months”. I was on a deadline, so I finally exported it to Word and edited it in Word where I needed to add ‘months’. Thank you for at least looking at it. The crunch is off, but I’d still be interested in a solution, if someone has one.
-
WSruirib
AskWoody LoungerNovember 7, 2012 at 9:33 am #1355349Datediff can be configured to return the result in whatever type of interval you want: http://www.techonthenet.com/access/functions/date/datediff.php
-
Jason Musgrove
AskWoody Plus -
WS79schultz
AskWoody Lounger -
Jason Musgrove
AskWoody PlusNovember 10, 2012 at 4:37 pm #1356300so, you are only interested in “whole” months, then? The Datediff function simply subtracts the month numbers and returns the result, adding 12 for each additional year. If you want to round down to whole months (i.e. 364 days old = 11 months), then you are going to have to adjust the results to compensate for the difference in days and subtract one month. Try this
AGE: iif(datediff(“d”,[DOB],now())<365,datediff("m",[DOB],now()) – iif(datepart("d",now())-datepart("d",[DOB])<0,1,0) & " Months",datediff("YYYY",[DOB],now()))
notice that I trigger the "months" result based on 365 days old rather than "1 year", since datediff will return "1" year for the entire birth month. If the day of the month is greater than the day of the dob, I subtract 1 month to remove the incomplete month from the result. This sounds to me like what you are after.
-
WS79schultz
AskWoody Lounger -
WS79schultz
AskWoody Lounger -
WSpatt
AskWoody Lounger -
WSCronk
AskWoody LoungerNovember 15, 2012 at 4:04 pm #1357229There is a problem though catering for leap years with 366 days.
Your a better man than me with complex IIf statements, but the first part would be
IIf(DateSerial(Year(pDOB) + 1, Month(pDOB), Day(pDOB)) <= Date,…..But there seems to be issues with the rest because I get the results below for a birth date of 16 November 2011 (NB UK date format). I'd be using a function.
Cronk
17/11/2011 1
18/11/2011 12 Months
19/11/2011 12 Months
….
29/11/2011 12 Months
30/11/2011 12 Months
1/12/2011 10 Months
2/12/2011 10 Months
…
15/12/2011 10 Months
16/12/2011 11 Months
17/12/2011 11 Months
18/12/2011 11 Months
….
30/12/2011 11 Months
31/12/2011 11 Months
1/01/2012 9 Months
2/01/2012 9 Months
3/01/2012 9 Months -
WSpatt
AskWoody Lounger -
WSpatt
AskWoody Lounger -
Tom Wickerath
AskWoody PlusNovember 22, 2012 at 5:00 am #1358423You might want to try a custom function, written by Graham Seach and Doug Steele:
A More Complete DateDiff Function
http://www.accessmvp.com/djsteele/Diff2Dates.htmlI have attached a sample database, in Access 2000 file format, that includes two queries that call the “Diff2Dates” function.
32447-CalculateAgesNote: If you are running Access 2007 or 2010, make sure to trust the folder first, since this sample includes Visual Basic for Applications (VBA) code:
Dealing with the Trust Center
http://www.accessmvp.com/TWickerath/articles/trust.htmThe first query, “qryCalculateAges”, includes the original data from your spreadsheet, along with age calculations for November 5 (the date you started this thread), and the current system date on your computer as today’s date. The two calculated ages are presented in “ymd” (Year-Month-Day) format. The data is sorted by birth month and birth day (1/25, 2/15, 3/1, etc.).
In the second query, “”qryCalculateAgesWithNestedIIFStatements, I used a rather ugly series of nested IIF statements to show age in:
-
[*]Years only if they are 16 or older
[*]Years and months, if they are between 13 months to 15 years of age and
[*]Years, months and days, if they are 12 months or younger
-
-
WS79schultz
AskWoody Lounger
Viewing 12 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
hibernate activation
by
e_belmont
1 hour, 34 minutes ago -
Red Hat Enterprise Linux 10 with AI assistant
by
Alex5723
1 hour, 52 minutes ago -
Windows 11 Insider Preview build 26200.5603 released to DEV
by
joep517
4 hours, 57 minutes ago -
Windows 11 Insider Preview build 26120.4151 (24H2) released to BETA
by
joep517
4 hours, 58 minutes ago -
Fixing Windows 24H2 failed KB5058411 install
by
Alex5723
8 hours, 8 minutes ago -
Out of band for Windows 10
by
Susan Bradley
9 hours, 42 minutes ago -
Giving UniGetUi a test run.
by
RetiredGeek
16 hours, 39 minutes ago -
Windows 11 Insider Preview Build 26100.4188 (24H2) released to Release Preview
by
joep517
1 day ago -
Microsoft is now putting quantum encryption in Windows builds
by
Alex5723
22 hours, 15 minutes ago -
Auto Time Zone Adjustment
by
wadeer
1 day, 4 hours ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
1 day, 2 hours ago -
Manage your browsing experience with Edge
by
Mary Branscombe
7 hours, 1 minute ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
17 hours, 57 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
1 hour, 51 minutes ago -
Apps included with macOS
by
Will Fastie
32 minutes ago -
Xfinity home internet
by
MrJimPhelps
21 hours, 47 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
21 hours, 45 minutes ago -
Debian 12.11 released
by
Alex5723
2 days, 1 hour ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
2 days, 5 hours ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
1 day, 9 hours ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
1 hour, 38 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
2 days, 22 hours ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
2 days, 12 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
10 hours, 37 minutes ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
2 days, 17 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
2 days ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
1 day, 2 hours ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
3 days, 10 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
22 hours, 46 minutes ago -
Does windows update component store “self heal”?
by
Mike Cross
2 days, 21 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.