# Problem with date difference calculation

**URL:** https://meta.discourse.org/t/problem-with-date-difference-calculation/70960
**Category:** UX
**Created:** [September 28, 2017, 4:14pm UTC](https://meta.discourse.org/t/problem-with-date-difference-calculation/70960 "2017-09-28T16:14:50Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 28, 2017, 4:14pm UTC](https://meta.discourse.org/t/problem-with-date-difference-calculation/70960/1 "2017-09-28T16:14:50Z")

</div>

This is here on meta. First post dated Aug 25, next post, “2 months later” dated today. This is a PM. First post in thread also not 2 months ago.

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/6/4620dd50a05dc31a069463fb26a596e52d60dc84.jpg)

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [September 28, 2017, 4:19pm UTC](https://meta.discourse.org/t/problem-with-date-difference-calculation/70960/2 "2017-09-28T16:19:23Z")

</div>

This was a recent change - the “x days/months/years” later used to round down, now it rounds up. Perhaps is should just “round”, instead of using `floor` or `ceil`.

> <https://github.com/discourse/discourse/commit/451340d0583c009d2bf0fbdf7c40fc9a01b3b1cd>

cc @codinghorror @eviltrout

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 28, 2017, 4:34pm UTC](https://meta.discourse.org/t/problem-with-date-difference-calculation/70960/3 "2017-09-28T16:34:54Z")

</div>

Would that even be 1.5 @eviltrout?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 28, 2017, 4:41pm UTC](https://meta.discourse.org/t/problem-with-date-difference-calculation/70960/4 "2017-09-28T16:41:36Z")

</div>

OH! I guess this is the end of September, which is \> 1 month.

> [@jomaxro](#):
>
> . Perhaps is should just “round”, instead of using floor or ceil.

> [@codinghorror](#):
>
> Would that even be 1.5 @eviltrout?

No, but since it does `ceil` \> 1 month = 2 months. Seems like you want `round`.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 28, 2017, 5:28pm UTC](https://meta.discourse.org/t/problem-with-date-difference-calculation/70960/5 "2017-09-28T17:28:20Z")

</div>

Hmm the intent was for 1.0 - 1.499 to be “1 month” and 1.5 - 1.999 to be “2 months” @eviltrout.

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [September 28, 2017, 7:09pm UTC](https://meta.discourse.org/t/problem-with-date-difference-calculation/70960/6 "2017-09-28T19:09:32Z")

</div>

I changed it to use round.

[https://github.com/discourse/discourse/commit/c7aa354ee88ecd99cd9f42baa1aaae813776285d](https://github.com/discourse/discourse/commit/c7aa354ee88ecd99cd9f42baa1aaae813776285d)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 28, 2017, 7:17pm UTC](https://meta.discourse.org/t/problem-with-date-difference-calculation/70960/7 "2017-09-28T19:17:29Z")

</div>


