# Filtering DateTime range efficiently

**URL:** <https://discourse.julialang.org/t/filtering-datetime-range-efficiently/5727>\
**Category:** General Usage\
**Created:** [September 5, 2017, 2:10pm UTC](https://discourse.julialang.org/t/filtering-datetime-range-efficiently/5727 "2017-09-05T14:10:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jan\_Dolinsky](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jan_dolinsky/32/31347_2.png) [@Jan\_Dolinsky](https://discourse.julialang.org/u/Jan_Dolinsky)\
**Post date:** [September 5, 2017, 2:10pm UTC](https://discourse.julialang.org/t/filtering-datetime-range-efficiently/5727/1 "2017-09-05T14:10:15Z")

</div>

Hi,

I am studying how to work DateTime in Julia. The design is very intuitive. Well done! The possibility to create a DateTime range is particularly interesting.

Imagine a range as follows:

```julia
a = DateTime(2017, 1, 1, 0, 0)
b = DateTime(2017, 1, 2, 23, 45)
s = Dates.Minute(15)

dr = a:s:b

```

What is an effective way to filter, say every 4th and 5th quarter-hour, i.e. 2017-01-01 01:00:00, 2017-01-01 01:15:00, 2017-02-01 01:00:00, 2017-01-01 01:15:00 or say every 47th and 48th quarter-hour ? In reality a DateTime range could be much longer, e.g. several years.

The following works but I wonder whether this is the way it should be.  
`filter(x->Dates.hour(x)==1 && Dates.minute(x) in [0, 15], tr)`

Thanks,  
Jan
