Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating Age for future dates

Status
Not open for further replies.

spartansFC

Programmer
Apr 1, 2009
165
GB

Hi

I have a list of children that may appear in different financial years and I need to work out their age based off this,
in the example below Child1 was born on 12 Feb 2008 and appears in 3 financial years.

Is there a way to calculate his next birthday based off Calc_Year and then therefore be able to calculate his age.

fin_year and calc_year are automatically pulled through in the query as the user selects a term on the form, i.e "spring 2011"
which on the table is associated with fin_year and calc_year

The only but I'm struggling with is the "next birthday in calc year".

Michael



Code:
[u]Childsname	DOB	        fin_Year    calc_Year	Next Birthday in calc_Year	Age[/u]
Child1	        12-Feb-08	2010/11	    2010	12-Feb-10	                 2
Child1	        12-Feb-08	2011/12	    2011	12-Feb-11	                 3
Child1	        12-Feb-08	2012/13	    2012	12-Feb-12	                 4
 
Hi,

What have you tried and what were the results?

Logic leads to evaluating if current is less than month & day then this year else next.
 

thanks for the reply but I worked it out in excel and then applied it to access, basically I calculated a few different fields in the query

I had to just show the year for the childs DOB
Code:
YR: Year([dteChildDOB])

then I had to calculate the difference between the calc_year and YR
Code:
 YRDiff: [strCalc_year]-[YR]

and finally had to add the YRDiff to the child's DOB to show the next birthdays in the financial years
Code:
NextBirthday: DateAdd("yyyy",+[YRDIFF],[dteChildDOB])

I should have thought about it more but thanks again

the output I get below is from the query which matches my example

Code:
[u]Childsname	dteChildDOB	strFinancialYear	strCalc_year	YR	YRDiff	NextBirthday[/u]
Child1    	12-Feb-08	2010/11	                2010	       2008	2	12-Feb-10
Child1  	12-Feb-08	2011/12	                2011	       2008	3	12-Feb-11
Child1   	12-Feb-08	2011/12	                2011	       2008	3	12-Feb-11
Child1  	12-Feb-08	2012/13	                2012	       2008	4	12-Feb-12

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top