只有DATE在MySQL {D}中的DATETIME列中

时间:2015-07-30 10:21:28

标签: c# mysql

美好的一天,我正在使用C#进行应用程序,并连接到Mysql数据库。我有一个类型为datetime的列,并且从应用程序中执行select也会给我发送时间。只有我对这个日期感兴趣。

MySqlCommand comando = new MySqlCommand();
            comando.Connection = conexion;
            comando.CommandText = "SELECT codgrupo,fecha,ciudad FROM actuacion";
            MySqlDataReader DR = comando.ExecuteReader();
            while (DR.Read())
            {
                ListViewItem ITEM = lvact.Items.Add(DR["codGrupo"].ToString());
                ITEM.SubItems.Add(DR["fecha"].ToString());
                ITEM.SubItems.Add(DR["ciudad"].ToString());
            }
            DR.Close();
            conexion.Close();

2 个答案:

答案 0 :(得分:0)

您可以通过Date属性获取C#DateTime变量的日期部分:

var myDateOnly = myDateTime.Date;

答案 1 :(得分:0)

使用此查询:

SELECT DATE(YourDate)
FROM yourTable