windowsforms-18120-controls-and-libraries-spreadsheet-examples-filter-data-how-to-apply-a-custom-date-filter.md
This example demonstrates how to specify the custom filter criteria to display dates that are before, after or equal to the specified date, or between two dates.
// Enable filtering for the specified cell range.
CellRange range = worksheet["B2:E23"];
worksheet.AutoFilter.Apply(range);
// Filter values in the "Reported Date" column to display dates that are between June 1, 2014 and February 1, 2015.
worksheet.AutoFilter.Columns[3].ApplyCustomFilter(new DateTime(2014, 6, 1), FilterComparisonOperator.GreaterThanOrEqual, new DateTime(2015, 2, 1), FilterComparisonOperator.LessThanOrEqual, true);
' Enable filtering for the specified cell range.
Dim range As CellRange = worksheet("B2:E23")
worksheet.AutoFilter.Apply(range)
' Filter values in the "Reported Date" column to display dates that are between June 1, 2014 and February 1, 2015.
worksheet.AutoFilter.Columns(3).ApplyCustomFilter(New Date(2014, 6, 1), FilterComparisonOperator.GreaterThanOrEqual, New Date(2015, 2, 1), FilterComparisonOperator.LessThanOrEqual, True)