title: Elasticsearch Date Histogram buckets starts from wrong date
body: <p>I have ElasticSearch analytic query. It must aggregate sum by 7d buckets.
  Also I've use extended bounds.
  But result buckets starts from wrong date.
  Elastic 5.2.2 version.
  What I'm doing wrong?</p>
  <pre><code>{
    &quot;size&quot;: 0,
    &quot;query&quot;: {
      &quot;bool&quot;: {
        &quot;must&quot;: [
          {
            &quot;range&quot;: {
              &quot;doc.dateExecute&quot;: {
                &quot;from&quot;: &quot;2017-07-11&quot;,
                &quot;to&quot;: &quot;2017-07-31&quot;,
                &quot;include_lower&quot;: true,
                &quot;include_upper&quot;: true,
                &quot;boost&quot;: 1.0
              }
            }
          }
        ],
        &quot;disable_coord&quot;: false,
        &quot;adjust_pure_negative&quot;: true,
        &quot;boost&quot;: 1.0,
        &quot;_name&quot;: &quot;onDates&quot;
      }
    },
    &quot;aggregations&quot;: {
      &quot;time&quot;: {
        &quot;date_histogram&quot;: {
          &quot;field&quot;: &quot;doc.dateExecute&quot;,
          &quot;interval&quot;: &quot;7d&quot;,
          &quot;offset&quot;: 0,
          &quot;order&quot;: {
            &quot;_key&quot;: &quot;asc&quot;
          },
          &quot;keyed&quot;: false,
          &quot;min_doc_count&quot;: 0,
          &quot;extended_bounds&quot;: {
            &quot;min&quot;: &quot;2017-07-11&quot;,
            &quot;max&quot;: &quot;2017-07-31&quot;
          }
        },
        &quot;aggregations&quot;: {
          &quot;incomingAmount&quot;: {
            &quot;sum&quot;: {
              &quot;field&quot;: &quot;doc.incomingAmount&quot;
            }
          },
          &quot;outgoingAmount&quot;: {
            &quot;sum&quot;: {
              &quot;field&quot;: &quot;doc.outgoingAmount&quot;
            }
          }
        }
      }
    }
  }
  </code></pre>
  <p>But buckets starts from &quot;2017-07-06T00:00:00.000Z&quot; and goes by 7d intervals to &quot;2017-07-27T00:00:00.000Z&quot;.
  What I'm missing? Thanks!</p>
  <p><strong>Update 1</strong></p>
  <p>I'd try a many variants of query. Different timezones, ranges, disabling exteneded_bounds, intervals multiple 7 day. It's works good only for 1-3d intervals.</p>
  <p><strong>Update 2</strong>
  I have tried 7.x. Seems to work fine on latest versions.</p>