Accessクエリのフィルタリングに使用している2つのデータピッカーオブジェクトがあります。たとえば、2012年9月1日(開始日)と2012年9月5日(終了日)のクエリを実行すると、2012年9月1日午前12時から2012年9月4日11時59分までのすべてが表示されます。終了日をインクリメントするなどして、終了日の実際の暦日を含める方法はありますか?
これが私のコードです:
string startDate = dateTimePicker1.Text;
string endDate = dateTimePicker2.Text;
OleDbCommand command = new OleDbCommand();
command.Parameters.AddWithValue("@startDate", startDate);
command.Parameters.AddWithValue("@endDate", endDate);
try {
command.Connection = connect;
command.CommandText = "SELECT RecordID, TimeStamp, EmployeeName, AreaDescription FROM LoginRecords r, Employees e, Areas a WHERE (e.EmployeeID = r.EmployeeID) AND (a.AreaID = r.AreaID) AND (TimeStamp BETWEEN @startDate AND @endDate) ORDER BY TimeStamp";
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
tw.WriteLine(reader["RecordID"].ToString() + " " + reader["TimeStamp"].ToString() + " " + reader["EmployeeName"].ToString() + " " + reader["AreaDescription"].ToString() + ",");
listBox1.Items.Add(reader["RecordID"].ToString() + " " + reader["TimeStamp"].ToString() + " " + reader["EmployeeName"].ToString() + " " + reader["AreaDescription"].ToString() + ",");
}
}
catch (Exception ex){
MessageBox.Show("Error: " + ex.Message);
}