Conditional filter: consider the time part when filtering by dates

Options

by Flexmonster Pivot Table

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<div>
  <h2>How to filter dates by date and time</h2>
  <p>
    In this example, we show how the
    <a
      href="https://www.flexmonster.com/api/options-object/#filter-filterbydateandtime"
      target="_blank"
    >filterByDateAndTime</a> option affects the
    <a href="https://www.flexmonster.com/doc/filter-by-condition/" target="_blank"
    >conditional filter</a> for date fields.
  </p>
  <p>
    We have two Flexmonster instances with the same dataset and the same filter
    below. In the report for the first instance, the
    <code>filterByDateAndTime</code> is set to <code>false</code> (line 19 in the
    JavaScript box), and the conditional filter for date fields does not consider
    time:
  </p>
</div>

<div id="pivot-container1"></div>

<p>
  In the report for the second instance, the <code>filterByDateAndTime</code> is
  set to <code>true</code> (line 60 in the JavaScript box), and the conditional
  filter for date fields considers time:
</p>

<div id="pivot-container2"></div>

CSS

@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container1",
  componentFolder: "https://cdn.flexmonster.com/",
  height: 260,
  report: {
    dataSource: {
      type: "api",
      url: "https://olap.flexmonster.com:9500",
      index: "dateWithTime",
      mapping: {
        "D": {
          type: "datetime",
          caption: "Date"
        }
      },
    },
    options: {
      filter: {
        filterByDateAndTime: false
      }
    },
    slice: {
      rows: [{
        uniqueName: "D",
        filter: {
          query: {
            equal: "2019-03-08T07:26:00"
          }
        }
      }],
      columns: [{
        uniqueName: "[Measures]"
      }],
      measures: [{
        uniqueName: "Price",
        aggregation: "sum"
      }]
    },
  }
});

let pivot2 = new Flexmonster({
  container: "pivot-container2",
  componentFolder: "https://cdn.flexmonster.com/",
  height: 200,
  report: {
    dataSource: {
      type: "api",
      url: "https://olap.flexmonster.com:9500",
      index: "dateWithTime",
      mapping: {
        "D": {
          type: "datetime",
          caption: "Date"
        }
      },
    },
    options: {
      filter: {
        filterByDateAndTime: true
      }
    },
    slice: {
      rows: [{
        uniqueName: "D",
        filter: {
          query: {
            equal: "2019-03-08T07:26:00"
          }
        }
      }],
      columns: [{
        uniqueName: "[Measures]"
      }],
      measures: [{
        uniqueName: "Price",
        aggregation: "sum"
      }]
    },
  }
});