Issue when Converting object of Type day to year

Note that you cannot calculate the age of a person in years when you know their age in days. So your function will need to work on both dates and not on their difference:

julia> function age(dob, date)
       age = Dates.year(date)- Dates.year(dob) -1
       if Dates.month(date)>Dates.month(dob) || (Dates.month(date)==Dates.month(dob) &&  Dates.day(date)>=Dates.day(dob))
         age += 1
       end
       return age
       end

PS: have another read on how to quote your code: PSA: how to quote code with backticks

3 Likes