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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. About dateTimePicker problem [modified]

About dateTimePicker problem [modified]

Scheduled Pinned Locked Moved C#
helpquestion
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 from,to; from=this.dateTimePicker1.Value.ToShortDateString(); to=this.dateTimePicker2.Value.ToShortDateString(); string str="select * from Furn_Info where Time between ‘"+from+"’ and ‘"+to+""; but i do not want to use "between.....and" i want to use ">=" and "<=", i use data SqL2000,Field "Time" Property is datetime,how should it be? please help me !thanks

    modified on Friday, November 27, 2009 8:41 AM

    R L 2 Replies Last reply
    0
    • M miss YY

      string from,to; from=this.dateTimePicker1.Value.ToShortDateString(); to=this.dateTimePicker2.Value.ToShortDateString(); string str="select * from Furn_Info where Time between ‘"+from+"’ and ‘"+to+""; but i do not want to use "between.....and" i want to use ">=" and "<=", i use data SqL2000,Field "Time" Property is datetime,how should it be? please help me !thanks

      modified on Friday, November 27, 2009 8:41 AM

      R Offline
      R Offline
      Rob Philpott
      wrote on last edited by
      #2

      string str="select * from Furn_Info where Time >= '"+from+"' and Time <= '"+to+"'"; Although you should think about parameterising the 'from' and 'to' rather than building a string with them.

      Regards, Rob Philpott.

      1 Reply Last reply
      0
      • M miss YY

        string from,to; from=this.dateTimePicker1.Value.ToShortDateString(); to=this.dateTimePicker2.Value.ToShortDateString(); string str="select * from Furn_Info where Time between ‘"+from+"’ and ‘"+to+""; but i do not want to use "between.....and" i want to use ">=" and "<=", i use data SqL2000,Field "Time" Property is datetime,how should it be? please help me !thanks

        modified on Friday, November 27, 2009 8:41 AM

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        As Rob said, avoid using strings for dates, it only yields problems when you move to a PC with a different datetime formatting. Store real dates and times and datetimes in your database, not strings, and use parameterized SQL, which accepts date/datetime values directly instead of strings. And please use PRE tags to show us your code. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


        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