Hello folks,
I am trying to learn how to write functions and have been working on a very simple one that should return the age of an animal in years. I have written one but it keeps returning zero when it should return years with decimal points, I am having trouble understanding what I am doing wrong and I am hoping someone can correct me.
This would be used in a query for a form or report. I was trying this with the immediate window feeding it random dates as follows:Code:Public Function AgeAtDeath( _ dtBirth As Date, _ dtDeath As Date) As Double Dim CalcAge As Double CalcAge = DateDiff("d", dtBirth, dtDeath) AgeAtDeath = Round(CalcAge, 1) End Function
?AgeAtDeath(2/13/2010, 2/15/2018)
but all it gives me is zero. Thank you for your help!