# How to decompose a DatePeriod or TimePeriod in tuple of (Y,m,d,H,M,S,s)?

**URL:** <https://discourse.julialang.org/t/how-to-decompose-a-dateperiod-or-timeperiod-in-tuple-of-y-m-d-h-m-s-s/74929>\
**Category:** General Usage\
**Tags:** dates\
**Created:** [January 20, 2022, 11:00am UTC](https://discourse.julialang.org/t/how-to-decompose-a-dateperiod-or-timeperiod-in-tuple-of-y-m-d-h-m-s-s/74929 "2022-01-20T11:00:25Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [January 20, 2022, 2:17pm UTC](https://discourse.julialang.org/t/how-to-decompose-a-dateperiod-or-timeperiod-in-tuple-of-y-m-d-h-m-s-s/74929/4 "2022-01-20T14:17:31Z")

</div>

FWIW, by calling Python from Julia we can obtain the number of years, months, days, etc., elapsed between two dates:

```julia
using PyCall
datetime = pyimport("datetime")
dateutil = pyimport("dateutil")
relativedelta = pyimport("dateutil.relativedelta")
d1 = datetime.datetime(2022,1,20)
d2 = datetime.datetime(2024,6,1)
dt = dateutil.relativedelta.relativedelta(d2, d1)

# results:
dt.years, dt.months, dt.days, dt.hours, dt.minutes, dt.seconds, dt.microseconds
(2, 4, 12, 0, 0, 0, 0)

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-decompose-a-dateperiod-or-timeperiod-in-tuple-of-y-m-d-h-m-s-s/74929)._
