如何select记录sqlite中的日期范围
How to select records for the date range in sqlite
我的 date
列是 Text
类型,我以 dd/mm/yyyy
格式存储值。我想从 dateTimePickers 中获取日期范围之间的记录。喜欢
select * from [Table] where date([date]) between
date(dtpicker1.value.ToShortDateString().ToString()) and
date(dtpicker2.value.ToShortDateString().ToString());
怎么做?
解决了,但有点棘手。
string qry = "select * from [table]";
DataTable vt = new DataTable();
SQLiteDataAdapter da = new SQLiteDataAdapter(q, connectionString);
da.Fill(vt);
foreach (DataRow row in vt.Rows)
{
if (Convert.ToDateTime(row["DATE"].ToString()) >= Convert.ToDateTime(FromDate)
&& Convert.ToDateTime(row["DATE"].ToString()) <= Convert.ToDateTime(ToDate))
{
continue;
}
else
{
row.Delete();
}
}
vt.AcceptChanges();
我的 date
列是 Text
类型,我以 dd/mm/yyyy
格式存储值。我想从 dateTimePickers 中获取日期范围之间的记录。喜欢
select * from [Table] where date([date]) between
date(dtpicker1.value.ToShortDateString().ToString()) and
date(dtpicker2.value.ToShortDateString().ToString());
怎么做?
解决了,但有点棘手。
string qry = "select * from [table]";
DataTable vt = new DataTable();
SQLiteDataAdapter da = new SQLiteDataAdapter(q, connectionString);
da.Fill(vt);
foreach (DataRow row in vt.Rows)
{
if (Convert.ToDateTime(row["DATE"].ToString()) >= Convert.ToDateTime(FromDate)
&& Convert.ToDateTime(row["DATE"].ToString()) <= Convert.ToDateTime(ToDate))
{
continue;
}
else
{
row.Delete();
}
}
vt.AcceptChanges();