# Finding an equality between two datetime

**URL:** https://discourse.julialang.org/t/finding-an-equality-between-two-datetime/71594
**Category:** New to Julia
**Tags:** dates
**Created:** [November 16, 2021, 3:25pm UTC](https://discourse.julialang.org/t/finding-an-equality-between-two-datetime/71594 "2021-11-16T15:25:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jnewbie](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jnewbie](https://discourse.julialang.org/u/jnewbie)
#### Post date: [November 16, 2021, 3:25pm UTC](https://discourse.julialang.org/t/finding-an-equality-between-two-datetime/71594/1 "2021-11-16T15:25:25Z")

</div>

Hi,

> a = [DateTime(“2021-08-02T10:00:00”), DateTime(“2021-08-05T07:00:00”), DateTime(“2021-08-05T07:00:00”)]

> b = DateTime(“2021-08-05T07:00:00”)

> for i in 1:length(a)  
> print(findall(b == a[i]))  
> end

Result : Int64Int64Int64Int64Int64

I am trying to find the positions in a where a==b (here position 3) but as you can see the result is not what I expected. Does anyone have any ideas ?  
(I tried with occursin but it only works with stings)

Thank you,

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [November 16, 2021, 3:29pm UTC](https://discourse.julialang.org/t/finding-an-equality-between-two-datetime/71594/2 "2021-11-16T15:29:03Z")

</div>

Maybe like this:

```julia
julia> a = [DateTime("2021-08-02T10:00:00"),
            DateTime("2021-08-05T07:00:00"),
            DateTime("2021-08-05T07:00:00")];

julia> b = DateTime("2021-08-05T07:00:00");

julia> findall(x -> x == b, a)
2-element Vector{Int64}:
 2
 3

```

---

<div class="post-metadata">

### Author: ![jnewbie](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@jnewbie](https://discourse.julialang.org/u/jnewbie)
#### Post date: [November 16, 2021, 3:45pm UTC](https://discourse.julialang.org/t/finding-an-equality-between-two-datetime/71594/3 "2021-11-16T15:45:41Z")

</div>

Thanks !

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [November 16, 2021, 4:20pm UTC](https://discourse.julialang.org/t/finding-an-equality-between-two-datetime/71594/4 "2021-11-16T16:20:11Z")

</div>

You could also do `a .== b` to get a bit array, or to get the indices: `eachindex(a)[a .== b]`
