[]
Gets or sets a value indicating whether the date filter should use whole days in its filtering criteria.
This option is used with Add(PivotFilterType, object, object, PivotFilterOptions) when creating a date filter and determining whether the filter criteria should match by whole day instead of by time.
public bool WholeDayFilter { get; set; }
Public Property WholeDayFilter As Boolean
worksheet.Range["A1:B4"].Value = new object[,] {
{"Date", "Amount"},
{new DateTime(2024, 1, 1, 8, 30, 0), 100},
{new DateTime(2024, 1, 1, 17, 45, 0), 200},
{new DateTime(2024, 1, 2, 9, 0, 0), 300}
};
IPivotCache pivotCache = workbook.PivotCaches.Create(worksheet.Range["A1:B4"]);
IPivotTable pivotTable = worksheet.PivotTables.Add(pivotCache, worksheet.Range["D1"], "DatePivot");
IPivotField dateField = pivotTable.PivotFields["Date"];
dateField.Orientation = PivotFieldOrientation.RowField;
pivotTable.PivotFields["Amount"].Orientation = PivotFieldOrientation.DataField;
PivotFilterOptions options = new PivotFilterOptions();
options.WholeDayFilter = true;
IPivotFilter filter = dateField.PivotFilters.Add(
PivotFilterType.DateBetween,
new DateTime(2024, 1, 1),
new DateTime(2024, 1, 1, 23, 59, 59),
options);
bool wholeDayFilter = filter.WholeDayFilter;