Here is my complete example, tested in VS2017 with .NET 4.5.1:
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;
namespace TestForm1
{
public partial class Form1 : Form
{
DataTable dt1 = new DataTable();
public Form1()
{
InitializeComponent();
Test();
}
private void Test()
{
dt1.Columns.Add("Shift Start", typeof(DateTime));
dt1.Columns.Add("employee_id", typeof(string));
dt1.Columns.Add("employee_name", typeof(string));
dt1.Columns.Add("Shift End", typeof(DateTime));
DateTime d = DateTime.Now;
dt1.Rows.Add(d.AddMinutes(-10), "1", "PRINCE", d.AddMinutes(-1));
dt1.Rows.Add(d, "2", "KING", d.AddMinutes(2));
dt1.Rows.Add(d.AddMinutes(1), "3", "PAUPER", d.AddMinutes(2));
IEnumerable<DataRow> selectedRows = dt1.AsEnumerable()
.Where(row => (row.Field<DateTime>("Shift Start") <= d) && (d <= row.Field<DateTime>("Shift End")));
foreach (DataRow row in selectedRows)
{
Console.WriteLine("{0}, {1}", row[0], row[1]);
}
}
}
}