# Issue when Converting object of Type day to year

**URL:** <https://discourse.julialang.org/t/issue-when-converting-object-of-type-day-to-year/20560>\
**Category:** General Usage\
**Tags:** dates\
**Created:** [February 7, 2019, 7:40pm UTC](https://discourse.julialang.org/t/issue-when-converting-object-of-type-day-to-year/20560 "2019-02-07T19:40:40Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [February 7, 2019, 8:02pm UTC](https://discourse.julialang.org/t/issue-when-converting-object-of-type-day-to-year/20560/2 "2019-02-07T20:02:36Z")

</div>

What you were looking for is `Dates.Year`, but that does not work the way you want it either because a number of days cannot be converted into years as years have a variable number of days.

Two possible solutions are:

```julia
julia> Dates.year(d1) - Dates.year(d2)
9

julia> Dates.days(d1-d2)/365.25
9.100616016427105

```

PS: have a read through [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757).

---

_[View the full topic](https://discourse.julialang.org/t/issue-when-converting-object-of-type-day-to-year/20560)._
