If you are only trying to get the legal age of the patient, there is no need to go through all that work, unless I am missing something.
Instead of converting lifespan to seconds, then back to years, all you need to do is compare dates. That will get you your difference. Also, I would use a date listed as an admit or discharge date in your message, as I am wary of using the current date in any messages. Your thread could get held up if someone was born on 1/8 and the message was held up since 1/7, your age would be compromised.
In plain English, subtract the year of birth (1984 in my case) from the current year (2014). For me, specifically, that would make 30.
2014 – 1984 = 30
Now, compare the MMDD of the DOB and the admit/discharge/current date. For me that would be 10/12 (my birthday) and we will use today’s date of 01/08. If the birthday is greater than the current date, then subtract one year from the age.
1012 > 0108, so we would decrease 30 by 1 to get 29.
I am 29 years old, but will turn 30 on 10/12. Does that make sense? So on October 11th, 1012 is still greater than 1011. But on my birthday 1012 is not greater than 1012.