julia> m
6-element Array{Date,1}:
 2017-03-01
 2017-04-01
 2017-05-01
 2017-06-01
 2017-07-01
 2017-08-01
julia> (m.>Date("2017-04-01")) .& (m.<Date("2017-08-01"))
6-element BitArray{1}:
 0
 0
 1
 1
 1
 0
something like range(m t1,t1)
?
Paul
julia> m
6-element Array{Date,1}:
 2017-03-01
 2017-04-01
 2017-05-01
 2017-06-01
 2017-07-01
 2017-08-01
julia> (m.>Date("2017-04-01")) .& (m.<Date("2017-08-01"))
6-element BitArray{1}:
 0
 0
 1
 1
 1
 0
something like range(m t1,t1)
?
Paul
The question title is a bit hard to understand, but is the following what you want?
julia> m = [Date("2017-$i-01") for i in 3:8]
6-element Array{Date,1}:
 2017-03-01
 2017-04-01
 2017-05-01
 2017-06-01
 2017-07-01
 2017-08-01
julia> flags = (m.>Date("2017-04-01")) .& (m.<Date("2017-08-01"))
6-element BitArray{1}:
 0
 0
 1
 1
 1
 0
julia> m[flags]
3-element Array{Date,1}:
 2017-05-01
 2017-06-01
 2017-07-01
I think the question is how to create a range of dates that can be used as a selector?
julia> using Dates
julia> mydaterange = Date(2017, 3, 1):Month(1):Date(2017, 8, 1)
Date("2017-03-01"):Month(1):Date("2017-08-01")
julia> collect(mydaterange)
6-element Array{Date,1}:
 2017-03-01
 2017-04-01
 2017-05-01
 2017-06-01
 2017-07-01
 2017-08-01
creates a range object consisting of dates, which efficiently stores the same entries as your m above. Your second line suggests you want to check whether something is in a range, which could be done by something like
in(Date(2007, 5, 1):Month(1):Date(2007, 7, 1)).(m)
but note that using > and < isn’t necessarily the same as using in with a range of dates, as the range stores only the exact dates at the given steps, not all dates in between (e.g. Date(2017, 4, 1) is >Date(2017, 4, 2), but is not in the date range, as the range in this example only has the first of each month)
It is nice
julia> m
3-element Array{Date,1}:
 2017-04-01
 2017-05-01
 2017-06-01
julia> mydaterange
Date("2017-03-01"):Month(1):Date("2017-08-01")
julia> in(m).(mydaterange)
6-element BitArray{1}:
 0
 1
 1
 1
 0
 0