このクエリで日付を使用する日付ピッカーが 2 つあります。
da = new SqlDataAdapter(@"
select * from TotalBill
where SaudaDate between
convert(datetime,'" + dtpForDate.Value.Date.ToString("MM/dd/yyyy") + "')
and convert(datetime,'" + dtpToDate.Value.Date.ToString("MM/dd/yyyy") + "')"
, con);
DataSet ds = new DataSet();
da.Fill(ds);
gvDailyBill.DataSource = ds.Tables[0];
ある日を照会したい場合、両方の日付ピッカーを同じ日に設定することはできませんが、希望するFrom
日に設定し、それ以降の日に設定する必要がありTo
ます。そうしないと、クエリは次のようになります。
select * from totalbill where SaudaDate between '1/2/2013' and '1/2/2013'
もちろん、これは0行を返します。コードまたはクエリを変更して、日付ピッカーで同じ日を選択できるようにするにはどうすればよいですか?