convert problem !
-
string mm = dateTimePicker1.Value.ToShortDateString().ToString(); string nn = dateTimePicker2.Value.ToShortDateString().ToString(); SqlCommand SCD = new SqlCommand("select * from table_inf where tim>=@mm and tim<=@nn", Conn); SCD.Parameters.AddWithValue("@mm", mm); SCD.Parameters.AddWithValue("@nn", nn); sqlDataAdapter1.SelectCommand = SCD; sqlDataAdapter1.Fill(DT); Conn.Open(); dataGridView1.DataSource = DT;
when i chosen dateTimePicker1 on today and chosen dateTimePicker2 on today too,it can't select Today'data....when you want to select today'data,you must change dateTimePicker2 on tomorrow,it's trouble! How can i chosen dateTimePicker1 on today and chosen dateTimePicker2 on today also can chosen Today's Data! i try to change "tim" to "convert(varchar(12),tim,105)",but it also do not work for me. i don't know how to change my Code ,thanks to everyone! i,m poor in english,sorry i use DATA sql2000 i have put this problem on here twice,thanks to everyone -
string mm = dateTimePicker1.Value.ToShortDateString().ToString(); string nn = dateTimePicker2.Value.ToShortDateString().ToString(); SqlCommand SCD = new SqlCommand("select * from table_inf where tim>=@mm and tim<=@nn", Conn); SCD.Parameters.AddWithValue("@mm", mm); SCD.Parameters.AddWithValue("@nn", nn); sqlDataAdapter1.SelectCommand = SCD; sqlDataAdapter1.Fill(DT); Conn.Open(); dataGridView1.DataSource = DT;
when i chosen dateTimePicker1 on today and chosen dateTimePicker2 on today too,it can't select Today'data....when you want to select today'data,you must change dateTimePicker2 on tomorrow,it's trouble! How can i chosen dateTimePicker1 on today and chosen dateTimePicker2 on today also can chosen Today's Data! i try to change "tim" to "convert(varchar(12),tim,105)",but it also do not work for me. i don't know how to change my Code ,thanks to everyone! i,m poor in english,sorry i use DATA sql2000 i have put this problem on here twice,thanks to everyoneYou just posted once a bit earlier same question and you have some answers too for your question.
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com
-
string mm = dateTimePicker1.Value.ToShortDateString().ToString(); string nn = dateTimePicker2.Value.ToShortDateString().ToString(); SqlCommand SCD = new SqlCommand("select * from table_inf where tim>=@mm and tim<=@nn", Conn); SCD.Parameters.AddWithValue("@mm", mm); SCD.Parameters.AddWithValue("@nn", nn); sqlDataAdapter1.SelectCommand = SCD; sqlDataAdapter1.Fill(DT); Conn.Open(); dataGridView1.DataSource = DT;
when i chosen dateTimePicker1 on today and chosen dateTimePicker2 on today too,it can't select Today'data....when you want to select today'data,you must change dateTimePicker2 on tomorrow,it's trouble! How can i chosen dateTimePicker1 on today and chosen dateTimePicker2 on today also can chosen Today's Data! i try to change "tim" to "convert(varchar(12),tim,105)",but it also do not work for me. i don't know how to change my Code ,thanks to everyone! i,m poor in english,sorry i use DATA sql2000 i have put this problem on here twice,thanks to everyoneThe value of mm is the same as the value of nn. You are cutting the time part which is the most important here. You should check dates between this interval [15.12.2009 00:00:00.001 - 15.12.2009 23:59:59.998] (and change the format in desired culture) I didn't notice that this question is re-posted! Man this is kind a rude! You've already got a good answer, so why re-post ?!