怎么判断数据的时间datetime跟dateTimePicker1控件的时间 要求只判断年月日,如上图正在根据dateTimePicker1控件的时间进行搜索 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 this.dateTimePicker1.CustomFormat ="yyyy-MM-dd"; this.dateTimePicker1.Format= System.Windows.Forms.DateTimePickerFormat.Custom; string s = this.dateTimePicker1.Text; if (dataTimePicker1.Value == DateTime.Now) ... private void button2_Click(object sender, EventArgs e) { DateTime time1 = new DateTime(2011, 6, 25, 23, 37, 0, DateTimeKind.Local); TimeSpan timespan = dateTimePicker1.Value - time1; if (timespan.Ticks >= 0) { MessageBox.Show("Picked time is new"); } else { MessageBox.Show("Picked time is old"); } } 用C#dateTimePicker1.Value.Date判断好久没用过这个控件了。。也可以用ToString方法格式化字符串。。再比较 要看你入住时间,数据库存储的是什么格式,如果是 2011-01-01,就像我那么写就可以得到 dateTimePicker1选择的年月日了然后 this.dateTimePicker1.CustomFormat ="yyyy-MM-dd";this.dateTimePicker1.Format= System.Windows.Forms.DateTimePickerFormat.Custom;string s = this.dateTimePicker1.Text;//拼写查询SQL string strSql = " select * from table1 where 入住时间= '"+ s+"';";//执行查询,填充到DataSet 里执行数据库查询,返回 DataSet ds datagrid1.DataSouce = ds.Table[0]; MessageBox.Show(dateTimePicker1.Value.ToShortDateString()); 开发VS2008插件怎么添加菜单项 在vb ent中,如何利用treeview和listview实习资源管理界面 一个关于反射的问题 假如有一字符串(001,002,001,003,002,001,003)如何能筛选出相同的,最后只得到001,002,003 想用C#写一个程序监控软件?有些小问题不会? 求语音聊天原代码,急!在线等! WinForm中如何展示PDF文件 C#编写画图板问题 SQL错误! 如何用存储过程删除数据库记录? comboxbox控件,为其 selectedvalue赋值,如果combobox并不存在这个值,如何处理呢? 求电子书编译原理
this.dateTimePicker1.CustomFormat ="yyyy-MM-dd";
this.dateTimePicker1.Format= System.Windows.Forms.DateTimePickerFormat.Custom;
string s = this.dateTimePicker1.Text;
...
private void button2_Click(object sender, EventArgs e)
{
DateTime time1 = new DateTime(2011, 6, 25, 23, 37, 0, DateTimeKind.Local);
TimeSpan timespan = dateTimePicker1.Value - time1; if (timespan.Ticks >= 0)
{
MessageBox.Show("Picked time is new");
}
else
{
MessageBox.Show("Picked time is old");
}
}
this.dateTimePicker1.CustomFormat ="yyyy-MM-dd";
this.dateTimePicker1.Format= System.Windows.Forms.DateTimePickerFormat.Custom;
string s = this.dateTimePicker1.Text;//拼写查询SQL
string strSql = " select * from table1 where 入住时间= '"+ s+"';";
//执行查询,填充到DataSet 里执行数据库查询,返回 DataSet ds datagrid1.DataSouce = ds.Table[0];
MessageBox.Show(dateTimePicker1.Value.ToShortDateString());