# Dividing a number by the number of days between dates

**URL:** https://discourse.julialang.org/t/dividing-a-number-by-the-number-of-days-between-dates/57728
**Category:** New to Julia
**Created:** [March 22, 2021, 3:25pm UTC](https://discourse.julialang.org/t/dividing-a-number-by-the-number-of-days-between-dates/57728 "2021-03-22T15:25:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nash/32/14482_2.png) [@Nash](https://discourse.julialang.org/u/Nash)
#### Post date: [March 22, 2021, 3:25pm UTC](https://discourse.julialang.org/t/dividing-a-number-by-the-number-of-days-between-dates/57728/1 "2021-03-22T15:25:53Z")

</div>

I am working with dates in the format m-d-yyyy for the purpose of computing the average stock return between two such dates. But when it comes to dividing the total return by the number of days between the two dates, I hit a problem.

How do I find the difference between two dates, and then use the derived number to divide the total return, thus finding the average return per day?

---

<div class="post-metadata">

### Author: ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)
#### Post date: [March 22, 2021, 3:34pm UTC](https://discourse.julialang.org/t/dividing-a-number-by-the-number-of-days-between-dates/57728/2 "2021-03-22T15:34:02Z")

</div>

Something like this would work

```julia
42.42/(today() - Date(2021, 1, 1)).value
# - 0.53025

```

because

```julia
 (today() - Date(2021, 1, 1)).value

```

gives 80.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [March 22, 2021, 5:12pm UTC](https://discourse.julialang.org/t/dividing-a-number-by-the-number-of-days-between-dates/57728/3 "2021-03-22T17:12:26Z")

</div>

While the above works, depending on your application you might want to ensure that you are dividing by the number of trading days rather than calendar days, cf the discussion here: [Getting the third Friday of the month - #4 by lungben](https://discourse.julialang.org/t/getting-the-third-friday-of-the-month/56787/4)
