I Want The Perfect Way To Calculate date of birth by year and month and day (1 Viewer)

mohamedmatter

Registered User.
Local time
Today, 05:45
Joined
Oct 25, 2015
Messages
112
There is a difference between the computer and manual method of calculating the date of birth
i attch file to error
 

Attachments

  • calclate ageAA.zip
    8.2 KB · Views: 84

GPGeorge

Grover Park George
Local time
Today, 05:45
Joined
Nov 25, 2004
Messages
1,877
Over the years I've become averse to the idea that anything can be perfect or the best. But let's tackle the requirement anyway.

Date of birth is a specific 24 hour period. Do you need to pinpoint that down to the hour and minute? Or are you only trying to find that 24 hour period, i.e. the date, from some set of inputs.

A far more common requirement, in fact, is to calculate age when supplied with the date of birth and the current date.... :unsure:
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:45
Joined
Sep 21, 2011
Messages
14,320
I doubt that very much. :)
It would just be your code that is incorrect.

@arnelgp has posted calculating age code many times here. Perhaps search for it, or look at similar threads at the bottom of this post.
 

GPGeorge

Grover Park George
Local time
Today, 05:45
Joined
Nov 25, 2004
Messages
1,877
Over the years I've become averse to the idea that anything can be perfect or the best. But let's tackle the requirement anyway.

Date of birth is a specific 24 hour period. Do you need to pinpoint that down to the hour and minute? Or are you only trying to find that 24 hour period, i.e. the date, from some set of inputs.

A far more common requirement, in fact, is to calculate age when supplied with the date of birth and the current date.... :unsure:
Oh, I see. You do want to calculate the age, not the birthdate.
 

mohamedmatter

Registered User.
Local time
Today, 05:45
Joined
Oct 25, 2015
Messages
112
I doubt that very much. :)
It would just be your code that is incorrect.

@arnelgp has posted calculating age code many times here. Perhaps search for it, or look at similar threads at the bottom of this post.
i look but no similar threads
 

CJ_London

Super Moderator
Staff member
Local time
Today, 13:45
Joined
Feb 19, 2013
Messages
16,619
this thread is about excel. You don't need VBA, just use the following formula

Year: =DATEDIF($A3,$B3,"y")
Month:=DATEDIF(EDATE(A3,C3*12),B3,"m")
Day:=DATEDIF(EDATE(A3,(C3*12)+D3),B3,"d")-1

I used the -1 for day as all depends on whether you are calculation the the start of that day, or the end of it.

where column
A=date of birth
B=date 'to'
C=Year
D=Month
E=Day

I don't agree with your manual calculations - how can you get 5 months between 31/07/2021 and 01/03/2022? ditto the other rows

For those using access the formula in a query would be

Years: =DateDiff("yyyy",[DOB],[DateTo])
Months:=DateDiff("m",DateAdd("yyyy",{Year],[DOB]),[DateTo])
Days:=DateTo-(DateAdd("m",[Year*12]+Months, [DOB])-1
 

isladogs

MVP / VIP
Local time
Today, 13:45
Joined
Jan 14, 2017
Messages
18,240
Or if you want to do it in Access, see
 

mohamedmatter

Registered User.
Local time
Today, 05:45
Joined
Oct 25, 2015
Messages
112
Thanks to all the members who gave me advice. and Who helped me solve.
 

Users who are viewing this thread

Top Bottom