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, 9 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
-
Search Forums only bring up my posts?
by
Deo
12 minutes ago -
Windows Spotlight broken on Enterprise and Pro for Workstations?
by
steeviebops
6 hours, 48 minutes ago -
Denmark wants to dump Microsoft for Linux + LibreOffice
by
Alex5723
8 hours, 15 minutes ago -
How to get Microsoft Defender to honor Group Policy Setting
by
Ralph
7 hours, 25 minutes ago -
Apple : Paragon’s iOS Mercenary Spyware Finds Journalists Target
by
Alex5723
17 hours, 34 minutes ago -
Music : The Rose Room – It’s Been A Long, Long Time album
by
Alex5723
18 hours, 39 minutes ago -
Disengage Bitlocker
by
CWBillow
8 hours, 37 minutes ago -
Mac Mini M2 Service Program for No Power Issue
by
Alex5723
20 hours, 39 minutes ago -
New Win 11 Pro Geekom Setup questions
by
Deo
25 minutes ago -
Windows 11 Insider Preview build 26200.5651 released to DEV
by
joep517
1 day, 3 hours ago -
Windows 11 Insider Preview build 26120.4441 (24H2) released to BETA
by
joep517
1 day, 3 hours ago -
iOS 26,, MacOS 26 : Create your own AI chatbot
by
Alex5723
1 day, 7 hours ago -
New PC transfer program recommendations?
by
DaveBoston
3 hours, 13 minutes ago -
Windows 11 Insider Preview Build 22631.5545 (23H2) released to Release Preview
by
joep517
1 day, 11 hours ago -
Windows 10 Build 19045.6029 (22H2) to Release Preview Channel
by
joep517
1 day, 11 hours ago -
Best tools for upgrading a Windows 10 to an 11
by
Susan Bradley
1 day ago -
The end of Windows 10 is approaching, consider Linux and LibreOffice
by
Alex5723
4 hours, 19 minutes ago -
Extended Windows Built-in Disk Cleanup Utility
by
bbearren
13 hours, 13 minutes ago -
Win 11 24H2 June 2025 Update breaks WIFI
by
dportenlanger
2 days, 6 hours ago -
Update from WinPro 10 v. 1511 on T460p?
by
CatoRenasci
1 day, 4 hours ago -
System Restore and Updates Paused
by
veteran
2 days, 9 hours ago -
Windows 10/11 clock app
by
Kathy Stevens
1 day, 20 hours ago -
Turn off right-click draw
by
Charles Billow
2 days, 12 hours ago -
Introducing ChromeOS M137 to The Stable Channel
by
Alex5723
2 days, 16 hours ago -
Brian Wilson (The Beach Boys) R.I.P
by
Alex5723
48 minutes ago -
Master patch listing for June 10, 2025
by
Susan Bradley
2 days, 17 hours ago -
Suggestions for New All in One Printer and a Photo Printer Windows 10
by
Win7and10
30 minutes ago -
Purchasing New Printer. Uninstall old Printer Software First?
by
Win7and10
2 days, 23 hours ago -
KB5060842 Issue (Minor)
by
AC641
1 day, 11 hours ago -
EchoLeak : Zero Click M365 Copilot leak sensitive information
by
Alex5723
3 days, 6 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.