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. Database & SysAdmin
  3. Database
  4. run date query in nvarchar type, how ?

run date query in nvarchar type, how ?

Scheduled Pinned Locked Moved Database
databasequestion
6 Posts 4 Posters 1 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.
  • E Offline
    E Offline
    E_Gold
    wrote on last edited by
    #1

    hi how i can run this: select * from men where Tdate between 01/01/01 and 02/02/02 but, Tdate is nvarchar type i work with sqlCE thank's

    L M 2 Replies Last reply
    0
    • E E_Gold

      hi how i can run this: select * from men where Tdate between 01/01/01 and 02/02/02 but, Tdate is nvarchar type i work with sqlCE thank's

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

      Hi, I would convert the string to a real datetime using convert(datetime, Tdate), then use that in a WHERE clause. it could be something like ... where convert(datetime, Tdate, 1)>='01/01/01' and convert(datetime, Tdate, 1)<='02/02/02' The '1' code specifies the format, see here[^]. I would also suggest to STORE dates as such, not as strings. :)

      Luc Pattyn


      Local announcement (Antwerp region): Lange Wapper? Neen!


      1 Reply Last reply
      0
      • E E_Gold

        hi how i can run this: select * from men where Tdate between 01/01/01 and 02/02/02 but, Tdate is nvarchar type i work with sqlCE thank's

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Luc has given you the solution but he was not forceful enough on storing the data as a datetime data type. If you do not change your data format to datetime then you will continiously run into this problem and all the associated datetime issues we see here regularly. STORE YOUR DATA IN THE RIGHT FORMAT.

        Never underestimate the power of human stupidity RAH

        L 1 Reply Last reply
        0
        • M Mycroft Holmes

          Luc has given you the solution but he was not forceful enough on storing the data as a datetime data type. If you do not change your data format to datetime then you will continiously run into this problem and all the associated datetime issues we see here regularly. STORE YOUR DATA IN THE RIGHT FORMAT.

          Never underestimate the power of human stupidity RAH

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

          Mycroft Holmes wrote:

          he was not forceful enough

          Sorry, I must be having an off-day then. :)

          Luc Pattyn


          Local announcement (Antwerp region): Lange Wapper? Neen!


          M 1 Reply Last reply
          0
          • L Luc Pattyn

            Mycroft Holmes wrote:

            he was not forceful enough

            Sorry, I must be having an off-day then. :)

            Luc Pattyn


            Local announcement (Antwerp region): Lange Wapper? Neen!


            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            As we are no longer encouraged to beat them with the sarcasm stick :sigh: , I see no reason not to scream it in their face.

            Never underestimate the power of human stupidity RAH

            L 1 Reply Last reply
            0
            • M Mycroft Holmes

              As we are no longer encouraged to beat them with the sarcasm stick :sigh: , I see no reason not to scream it in their face.

              Never underestimate the power of human stupidity RAH

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Mycroft Holmes wrote:

              As we are no longer encouraged to beat them with the sarcasm stick Sigh , I see no reason not to scream it in their face.

              Even though neither method has the desired effect in too many cases :mad:

              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