Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. convert problem !

convert problem !

Scheduled Pinned Locked Moved C#
helptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    miss YY
    wrote on last edited by
    #1

    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

    B S 2 Replies Last reply
    0
    • M miss YY

      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

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      You 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

      1 Reply Last reply
      0
      • M miss YY

        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

        S Offline
        S Offline
        Shorgov
        wrote on last edited by
        #3

        The 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 ?!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups