The Select method can be used with dates. In this example, we create a DataTable. Each row has a DateTime cell. We then query with the Select method.
using System;
using System.Data;
class Program
{
static void Main()
{
// Create table.
// ... Add two columns and three rows.
DataTable table = new DataTable(
"Widgets");
table.Columns.Add(new DataColumn(
"ID", typeof(int)));
table.Columns.Add(new DataColumn(
"Date", typeof(DateTime)));
table.Rows.Add(100, new DateTime(2001, 1, 1));
table.Rows.Add(200, new DateTime(2002, 1, 1));
table.Rows.Add(300, new DateTime(2003, 1, 1));
// Select by date.
DataRow[] result = table.Select(
"Date > #6/1/2001#");
// Display.
foreach (DataRow row in result)
{
Console.WriteLine(row[
"ID"]);
}
}
}
200
300