【发布时间】:2012-11-24 05:26:42
【问题描述】:
我的 Linq 不太好,我想进行查询以获取正确的数据。我有一个包含这些列的数据表:
我想通过 TIMEFROM 和 TIMETO 列进入数据表得到这个 = 10.12.2012 不是 10.12.2012 00:00:00。
我该怎么做:我的数据表的名称是 table。
MySqlCommand selectcommand = new MySqlCommand(sqlcommand, connection);
MySqlDataAdapter adapter = new MySqlDataAdapter(selectcommand);
DataTable table = new DataTable(TABLE);
adapter.Fill(table);
table = table.AsEnumerable().Where(r => r.Field<int>("Activate") == 1).CopyToDataTable();
//i need the shorter form
connection.Open();
selectcommand.ExecuteReader();
return table;
【问题讨论】:
-
列是什么意思?您只想要日期并缩短它们还是按时间排序的整个表格?
-
认为图片上传不正确。
-
要从 DateTime 对象中省略小时,请使用 .ToString("d")
-
最好是 myVar.ToShortDateString()
-
获得数据后:dateTime = dateTime.ToShortDateString();
标签: c# asp.net sql linq datatable