Hi I have a form that I’m working in–how does access subtract the DOB from the date of death? would it have to be in the query or in the form?
![]() |
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 |
-
Subtract 2 dates in access 2003
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Subtract 2 dates in access 2003
- This topic has 5 replies, 4 voices, and was last updated 13 years, 8 months ago.
AuthorTopicWSbuckshot
AskWoody LoungerSeptember 9, 2011 at 1:27 pm #478897Viewing 3 reply threadsAuthorReplies-
WSMarkLiquorman
AskWoody LoungerSeptember 9, 2011 at 2:07 pm #1297150Hi I have a form that I’m working in–how does access subtract the DOB from the date of death? would it have to be in the query or in the form?
What are you trying to get out of this subtraction. You could just do this:
[INDENT]Result = DateOfDeath – DOB[/INDENT]Where “Result” will be the # of days between the 2 dates. Or you could use the DateDiff function if you wanted some other measure.
-
WSbuckshot
AskWoody Lounger
-
-
WSjohnhutchison
AskWoody LoungerSeptember 9, 2011 at 6:02 pm #1297181This subtraction is just an example of a calculated field.
You can perform calculations either in a query or directly in a form/report.
In a query the syntax is : Result: [DateofDeath]-[DOB]
In a form you set the control source of a text box directly = [DateofDeath]-[DOB]
You could name the text box result if you want, but that is not essential.
-
WSHiTechCoach
AskWoody LoungerSeptember 11, 2011 at 2:30 pm #1297465I use this code in a standard module:
Code:Public Function myGetAge(ByVal bDate As Date) As String ‘ Written by datAdrenaline – modified by Cybercow Dim strTemp As String, dtTemp As Date Dim yrs As Long, mos As Long, dys As Long Dim dblTotalTime As Double Dim X As Integer ‘Ensure the start is LESS than the stop If bDate > Date Then MsgBox “No date greater than today is allowed.”, vbOKOnly + vbInformation, “Unacceptable Date” Exit Function End If ‘Get the years between the two dates yrs = DateDiff(“yyyy”, bDate, Date) yrs = yrs – Abs(DateAdd(“yyyy”, yrs, bDate) > Date) ‘Get the months between the two dates that exceed the years mos = DateDiff(“m”, bDate, Date) mos = mos – Abs(DateAdd(“m”, mos, bDate) > Date) – (yrs * 12) ‘Get the number of days between the two dates that exceed the years + months … dys = DateDiff(“n”, DateAdd(“m”, mos + yrs * 12, bDate), Date) 1440 ‘Build string for the “left” half of our time difference For X = 1 To 3 strTemp = strTemp & ” ” & Choose(X, yrs, mos, dys) & ” ” & Choose(X, “yrs”, “mos”, “dys”) Next X ‘Return the string myGetAge = mid(strTemp, 2) End Function
You can call it from a query.
Boyd Trimmell aka HiTechCoach
Microsoft MVP – Access Expert -
WSjohnhutchison
AskWoody LoungerSeptember 11, 2011 at 5:22 pm #1297488Boyd’s function does a similar job the one Buckshot asked about but not quite the same. His function myGetAge tells you how old someone is today. It accepts one parameter, a starting date, and uses the current date as the finish date. To use it to find the age at death you would need to modify the function to accept a second parameter, and use that instead of the Date function for the second date.
In his first response Mark asked what type of answer you are looking for.
Simple subtraction gives you just a number of days.
A function like Boyd’s would give a piece of text like: “34 Yrs 5 mths 12 days”
Another possible answer may just be the age in years.Do you need to do anything with the answer other than display it on the screen? If you wanted to perform any further calculations, for example, you might need the answer to be a number.
Viewing 3 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
-
89 million Steam account details just got leaked,
by
Alex5723
8 hours, 7 minutes ago -
KB5058405: Linux – Windows dual boot SBAT bug, resolved with May 2025 update
by
Alex5723
8 hours, 15 minutes ago -
A Validation (were one needed) of Prudent Patching
by
Nibbled To Death By Ducks
2 hours, 41 minutes ago -
Master Patch Listing for May 13, 2025
by
Susan Bradley
1 hour, 37 minutes ago -
Installer program can’t read my registry
by
Peobody
1 hour, 13 minutes ago -
How to keep Outlook (new) in off position for Windows 11
by
EspressoWillie
21 hours, 45 minutes ago -
Intel : CVE-2024-45332, CVE-2024-43420, CVE-2025-20623
by
Alex5723
4 hours, 21 minutes ago -
False error message from eMClient
by
WSSebastian42
19 hours, 23 minutes ago -
Awoke to a rebooted Mac (crashed?)
by
rebop2020
1 day, 4 hours ago -
Office 2021 Perpetual for Mac
by
rebop2020
1 day, 5 hours ago -
AutoSave is for Microsoft, not for you
by
Will Fastie
2 hours, 16 minutes ago -
Difface : Reconstruction of 3D Human Facial Images from DNA Sequence
by
Alex5723
1 day, 9 hours ago -
Seven things we learned from WhatsApp vs. NSO Group spyware lawsuit
by
Alex5723
10 hours, 14 minutes ago -
Outdated Laptop
by
jdamkeene
1 day, 14 hours ago -
Updating Keepass2Android
by
CBFPD-Chief115
1 day, 20 hours ago -
Another big Microsoft layoff
by
Charlie
1 day, 19 hours ago -
PowerShell to detect NPU – Testers Needed
by
RetiredGeek
23 hours, 8 minutes ago -
May 2025 updates are out
by
Susan Bradley
12 hours, 45 minutes ago -
Windows 11 Insider Preview build 26200.5600 released to DEV
by
joep517
2 days, 1 hour ago -
Windows 11 Insider Preview build 26120.3964 (24H2) released to BETA
by
joep517
2 days, 1 hour ago -
Drivers suggested via Windows Update
by
Tex265
2 days, 1 hour ago -
Thunderbird release notes for 128 esr have disappeared
by
EricB
1 day, 23 hours ago -
CISA mutes own website, shifts routine cyber alerts to X, RSS, email
by
Nibbled To Death By Ducks
2 days, 8 hours ago -
Apple releases 18.5
by
Susan Bradley
2 days, 3 hours ago -
Fedora Linux 40 will go end of life for updates and support on 2025-05-13.
by
Alex5723
2 days, 10 hours ago -
How a new type of AI is helping police skirt facial recognition bans
by
Alex5723
2 days, 10 hours ago -
Windows 7 ISO /Windows 10 ISO
by
ECWS
19 hours, 6 minutes ago -
No HP software folders
by
fpefpe
2 days, 18 hours ago -
Which antivirus apps and VPNs are the most secure in 2025?
by
B. Livingston
1 day, 15 hours ago -
Stay connected anywhere
by
Peter Deegan
2 days, 23 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.