# Findfirst with dates

**URL:** <https://discourse.julialang.org/t/findfirst-with-dates/91419>\
**Category:** New to Julia\
**Tags:** dates\
**Created:** [December 8, 2022, 9:43am UTC](https://discourse.julialang.org/t/findfirst-with-dates/91419 "2022-12-08T09:43:37Z")\
**Posts on this page:** 2\
**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:** [December 8, 2022, 9:43am UTC](https://discourse.julialang.org/t/findfirst-with-dates/91419/1 "2022-12-08T09:43:37Z")

</div>

The following script throws an error, and I wonder what the correct syntax is for achieving what I want:

`id_date = findfirst(market_days_all, market_day)`

ERROR: MethodError: no method matching findfirst(::Vector{Date}, ::Date)

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [December 8, 2022, 9:51am UTC](https://discourse.julialang.org/t/findfirst-with-dates/91419/2 "2022-12-08T09:51:55Z")

</div>

The following works:

```julia
using Dates
market_day = Date(2022, 1, 1)
market_days_all = collect(Date(2021,12,1):Day(1):Date(2022,2,1))
id_date = findfirst(==(market_day), market_days_all)

```

I had to create some mock data to test this on, but the gist is that the `findfirst` function takes a function that tests for true or false (i.e. is it equal to `market_day`?), and a collection of things to test said function on.

You’ll find a lot more help if you just type `?` followed by the function you’re trying to use (i.e. `findfirst`) in the REPL.
