SearchOptionsDateFormats Property
Gets the collection of date formats for date range search. The default date formats are 'dd.MM.yyyy', 'MM/dd/yyyy', and 'yyyy-MM-dd'.

Namespace: GroupDocs.Search.Options
Assembly: GroupDocs.Search (in GroupDocs.Search.dll) Version: 20.8
Syntax
public DateFormatCollection DateFormats { get; }

Property Value

Type: DateFormatCollection
The collection of date formats for date range search.
Examples
The example demonstrates how to set the date formats for the search.
C#
string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
string query = "Einstein";

Index index = new Index(indexFolder); // Creating an index in the specified folder
index.Add(documentsFolder); // Indexing documents from the specified folder

SearchOptions options = new SearchOptions();
options.DateFormats.Clear(); // Removing default date formats
DateFormatElement[] elements = new DateFormatElement[]
{
    DateFormatElement.MonthTwoDigits,
    DateFormatElement.DayOfMonthTwoDigits,
    DateFormatElement.YearFourDigits,
};
// Creating a date format pattern 'MM/dd/yyyy'
DateFormat dateFormat = new DateFormat(elements, "/");
options.DateFormats.Add(dateFormat);

SearchResult result = index.Search(query, options); // Search in index
See Also