DateTime: Time division

Check also this related thread.

From which your example could be written, with the help of CompoundPeriods, as:

using Dates, CompoundPeriods
import Base: / , *
/(t::Dates.CompoundPeriod, x::Real) = canonicalize(Dates.CompoundPeriod(Millisecond(round(Int64,Dates.toms(t)/x))))
*(t::Dates.CompoundPeriod, x::Real) = canonicalize(Dates.CompoundPeriod(Millisecond(round(Int64,Dates.toms(t)*x))))

hr = Hour(1) |> CompoundPeriod
t1 = DateTime(2023, 1, 3)
r = 7.4
t2 = t1 + hr/r      # 2023-01-03T00:08:06.486

3 Likes