Time difference in year between table datetime values and now
Show older comments
I have a vector of datetime values. I would like to get a vector of years elapsed between the datetime values and the present. How do I do this?
I tried
years(MyTable.BirthDate- now)
and got
Error using years
Input data must be a real, numeric array, or a duration array. Use YEAR to extract year numbers from a
datetime array.
I tried
year(MyTable.BirthDate- now)
but it rounded the values, and I would like the decimal difference. How can I get, for example, that one of the entries is 6.8 years old today?
Accepted Answer
More Answers (0)
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!