# Using date difference for conditional

**URL:** https://discourse.julialang.org/t/using-date-difference-for-conditional/67801
**Category:** New to Julia
**Tags:** dates
**Created:** [September 7, 2021, 10:39am UTC](https://discourse.julialang.org/t/using-date-difference-for-conditional/67801 "2021-09-07T10:39:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sransome](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sransome/32/29810_2.png) [@sransome](https://discourse.julialang.org/u/sransome)
#### Post date: [September 7, 2021, 10:39am UTC](https://discourse.julialang.org/t/using-date-difference-for-conditional/67801/1 "2021-09-07T10:39:56Z")

</div>

I’m a new Julia user and feeling really dumb here because Dates are absolutely killing me. I just want to do something like  
if (Date1-Date2)\>1 # to represent the difference is than 1 day.  
do something  
else

My problem is that I cant work out how to convert the result of Day1-Day2 to an integer because Date1-Date2 returns “x Days”, clearly not an integer.

Any hints much appreciated.  
Thanks  
Steve

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [September 7, 2021, 10:55am UTC](https://discourse.julialang.org/t/using-date-difference-for-conditional/67801/2 "2021-09-07T10:55:51Z")

</div>

> [@sransome](#):
>
> if (Date1-Date2)\>1 # to represent the difference is than 1 day.

You can use:

```julia
if Date1-Date2 > Day(1)

```

---

<div class="post-metadata">

### Author: ![sransome](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sransome/32/29810_2.png) [@sransome](https://discourse.julialang.org/u/sransome)
#### Post date: [September 8, 2021, 2:48am UTC](https://discourse.julialang.org/t/using-date-difference-for-conditional/67801/3 "2021-09-08T02:48:41Z")

</div>

thanks heliosdrm.
