# How to round up DateTime to the next whole Hour?

**URL:** <https://discourse.julialang.org/t/how-to-round-up-datetime-to-the-next-whole-hour/107135>\
**Category:** New to Julia\
**Tags:** dates\
**Created:** [December 4, 2023, 11:29pm UTC](https://discourse.julialang.org/t/how-to-round-up-datetime-to-the-next-whole-hour/107135 "2023-12-04T23:29:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![atBNE](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@atBNE](https://discourse.julialang.org/u/atBNE)\
**Post date:** [December 4, 2023, 11:29pm UTC](https://discourse.julialang.org/t/how-to-round-up-datetime-to-the-next-whole-hour/107135/1 "2023-12-04T23:29:49Z")

</div>

How to round up DateTime to the next whole Hour? The Dates docs is heavy, and a beginner can get lost in it.

```julia
using Dates

function gvt(p1)
    dly = Hour(2) # a constant delay of 2 hours
    tym = now() # HOW TO round up tym to the next whole hour ?
    # ....
    tym = now() + dly
    # .... 
    if now() > tym
       # ....

```

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [December 4, 2023, 11:31pm UTC](https://discourse.julialang.org/t/how-to-round-up-datetime-to-the-next-whole-hour/107135/2 "2023-12-04T23:31:15Z")

</div>

```julia
julia> ceil(now(), Hour)

```

---

<div class="post-metadata">

**Author:** ![atBNE](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@atBNE](https://discourse.julialang.org/u/atBNE)\
**Post date:** [December 4, 2023, 11:34pm UTC](https://discourse.julialang.org/t/how-to-round-up-datetime-to-the-next-whole-hour/107135/3 "2023-12-04T23:34:28Z")

</div>

Thank you. That was a very quick reply, and it works!
