# \`DateTime\` arithmetic on \`Microsecond\` (or smaller) scale

**URL:** <https://discourse.julialang.org/t/datetime-arithmetic-on-microsecond-or-smaller-scale/102949>\
**Category:** Internals & Design\
**Tags:** dates, datetime\
**Created:** [August 18, 2023, 12:39pm UTC](https://discourse.julialang.org/t/datetime-arithmetic-on-microsecond-or-smaller-scale/102949 "2023-08-18T12:39:34Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![laborg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laborg/32/5474_2.png) [@laborg](https://discourse.julialang.org/u/laborg)\
**Post date:** [August 19, 2023, 7:13am UTC](https://discourse.julialang.org/t/datetime-arithmetic-on-microsecond-or-smaller-scale/102949/2 "2023-08-19T07:13:18Z")

</div>

I personally don’t need any finer precision than milliseconds when operating with `DateTime`s but I don’t like that various operations with Micro- and Nanoseconds are available without throwing a warning. Its feels like wrong advertising. If Julia allows to add periods to dates the result is expected to be accurate or the operation should error.  
Imagine operations on `String`s silently taking away a couple of chars because of limitations in the internal implementation. There would be no discussion that this isn’t the right behaviour.

It is also not coherent to allow operations with hidden truncating given that:

- Addition of `Millisecond`s and `Nanosecond`s result in a `CompoundPeriod` without losing accuracy:

```julia-repl
julia> Millisecond(1) + Nanosecond(1)
1 millisecond, 1 nanosecond

```

- Operations on periods alone do throw `InexactError`:

```julia
julia> Millisecond(1) / 2
ERROR: InexactError: Int64(0.5)

```

---

_[View the full topic](https://discourse.julialang.org/t/datetime-arithmetic-on-microsecond-or-smaller-scale/102949)._
