I Want The Perfect Way To Calculate date of birth by year and month and day

mohamedmatter

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

Attachments

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:
 
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.
 
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.
 
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
 
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
 
Or if you want to do it in Access, see
 
Thanks to all the members who gave me advice. and Who helped me solve.
 

Users who are viewing this thread

Back
Top Bottom