# \[Dates\] Division of Periods

**URL:** <https://discourse.julialang.org/t/dates-division-of-periods/76779>\
**Category:** New to Julia\
**Tags:** dates\
**Created:** [February 20, 2022, 12:50am UTC](https://discourse.julialang.org/t/dates-division-of-periods/76779 "2022-02-20T00:50:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vyacheslav\_Vorobyov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vyacheslav_vorobyov/32/26301_2.png) [@Vyacheslav\_Vorobyov](https://discourse.julialang.org/u/Vyacheslav_Vorobyov)\
**Post date:** [February 20, 2022, 12:50am UTC](https://discourse.julialang.org/t/dates-division-of-periods/76779/1 "2022-02-20T00:50:46Z")

</div>

Hi, I tried to use Dates module and divide Millseconds on Minutes and error happen.  
Why operation didn’t dispatch to method " /(::P, ::P) where P\<:Period" ?

Julia Version 1.6.5

```julia
julia> using Dates

julia> Dates.Millisecond(60_000) / Dates.Minute(1)
ERROR: MethodError: no method matching /(::Millisecond, ::Minute)
Closest candidates are:
  /(::StridedArray{P, N} where N, ::P) where P<:Period at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Dates\src\deprecated.jl:44
  /(::AbstractRange{var"#s814"} where var"#s814"<:P, ::P) where P<:Period at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Dates\src\ranges.jl:67
  /(::P, ::P) where P<:Period at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Dates\src\periods.jl:82
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

julia> Dates.Millisecond(60_000) isa Dates.Period
true

julia> Dates.Minute(1) isa Dates.Period
true

```

---

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [February 20, 2022, 1:13am UTC](https://discourse.julialang.org/t/dates-division-of-periods/76779/2 "2022-02-20T01:13:51Z")

</div>

For this dispatch to happened, the type of two objects need to be the same.

Try defining `/(::P,::Q) where {P<:Period, Q<:Period)` and it’ll work

---

<div class="post-metadata">

**Author:** ![George9000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/george9000/32/23619_2.png) [@George9000](https://discourse.julialang.org/u/George9000)\
**Post date:** [February 20, 2022, 1:16am UTC](https://discourse.julialang.org/t/dates-division-of-periods/76779/3 "2022-02-20T01:16:44Z")

</div>

It’s [this issue](https://github.com/JuliaLang/julia/issues/29395). On Julia 1.7.1 it was still giving the error above. But in the upcoming Julia 1.8, it has been addressed.

```julia
julia> versioninfo()
Julia Version 1.8.0-DEV.1483
Commit 76fa18281d (2022-02-09 22:23 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.0 (ORCJIT, cyclone)
Environment:
  JULIA_EDITOR = Emacs

julia> using Dates

julia> Dates.Millisecond(60_000) / Dates.Minute(1)
1.0

```

Not sure what platform you are on, but building the master branch should be [straightforward](https://github.com/JuliaLang/julia) on Linux.

---

<div class="post-metadata">

**Author:** ![Vyacheslav\_Vorobyov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vyacheslav_vorobyov/32/26301_2.png) [@Vyacheslav\_Vorobyov](https://discourse.julialang.org/u/Vyacheslav_Vorobyov)\
**Post date:** [February 20, 2022, 1:48am UTC](https://discourse.julialang.org/t/dates-division-of-periods/76779/5 "2022-02-20T01:48:44Z")

</div>

Ouch, I see, the method definition " /(::P, ::P) where P\<:Period" means that both arguments must be not just subtypes of Period, but also have exactly the same type which is not the case.

P.S. Until Julia 1.8, I decided to use in my code “/(promote(x,y)…)” because ‘x’ and ‘y’ could come in different combinations of Hour, Minute, Second, Millisecond, etc… .

---

<div class="post-metadata">

**Author:** ![Vyacheslav\_Vorobyov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vyacheslav_vorobyov/32/26301_2.png) [@Vyacheslav\_Vorobyov](https://discourse.julialang.org/u/Vyacheslav_Vorobyov)\
**Post date:** [February 20, 2022, 1:56am UTC](https://discourse.julialang.org/t/dates-division-of-periods/76779/6 "2022-02-20T01:56:08Z")

</div>

Good to know it is addressed in 1.8! Until that I’m ok to use my bypass solution.

---

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [February 20, 2022, 1:56am UTC](https://discourse.julialang.org/t/dates-division-of-periods/76779/7 "2022-02-20T01:56:23Z")

</div>

> [@Vyacheslav\_Vorobyov](#):
>
> Ouch, I see, the method definition " /(::P, ::P) where P\<:Period" means that both arguments must be not just subtypes of Period, but also have exactly the same type which is not the case.

Exactly that’s the intended behavior. Looking at the GitHub issue also shows that Dates definitions are not really convertible to each other’s as easily as you’ll think, but if promoting them works, that’s the right way to go for now.
