DateFormats
SearchOptions.DateFormats 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’.
public DateFormatCollection DateFormats { get; }
Property Value
The collection of date formats for date range search.
Examples
The example demonstrates how to set the date formats for the search.
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
- class DateFormatCollection
- class SearchOptions
- namespace GroupDocs.Search.Options
- assembly GroupDocs.Search