I'd like to select a day series, kind of like this:

```
SELECT generate_series(
   timestamp without time zone '2016-10-16',
   timestamp without time zone '2016-10-17',
   '1 day')

```

Further I got entities which always have a startdate and an enddate.
With the above query, I would like to select the amount (count) of entities, which have that day in the series being inside both dates.

Output would be (kinda) like this:
[select output](https://i.stack.imgur.com/2CaGp.png)

Any help is appreciated!

edit: Here is a sample table:

```
table occurrences (
    datestart DATE
    dateend DATE
)

```