set age_seconds [expr [clock scan now]-[clock scan $dob]]
set age_years [expr $age_seconds/86400/366]
echo $age_years
If you want to take this to a more exact, you may need to adjust your calculation of the variable age_seconds. The clock scan command returns the number of seconds from I beleive sometime in 1969. Not sure I have to check each time.
set age_seconds [expr [clock scan now]-[clock scan $dob]]
set age_years [expr $age_seconds/86400/366]
echo $age_years
I think that patients over 68 years old will have lived more than 2^31 seconds and overflow a signed integer. On TCL 8.5 this wouldn’t be a problem, but Cloverleaf is still on TCL 8.4 and age_seconds will be a negative number. I had to do something like this: