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. Database & SysAdmin
  3. Database
  4. sql functon

sql functon

Scheduled Pinned Locked Moved Database
databasehelpquestion
5 Posts 4 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.
  • T Offline
    T Offline
    Thanusree Duth
    wrote on last edited by
    #1

    how the datetime is written in a particular order using sql function?datetime format which i used is Dec 2 2010 9:40:45:000PM Dec 02, 2010 11:59:59:000PM Dec 3 2010 3:45:54:000AM Dec 3 2010 1:24:23:000AM Dec 3 2010 12:15:27:000AM how these datetimes in a correct order?pls help me...:confused:

    M M 2 Replies Last reply
    0
    • T Thanusree Duth

      how the datetime is written in a particular order using sql function?datetime format which i used is Dec 2 2010 9:40:45:000PM Dec 02, 2010 11:59:59:000PM Dec 3 2010 3:45:54:000AM Dec 3 2010 1:24:23:000AM Dec 3 2010 12:15:27:000AM how these datetimes in a correct order?pls help me...:confused:

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

      So you have made the most basic error in data storage, you have stored your dates as varchar. You will have trouble until you reformat your data to datetime. Do it NOW! However this may work on those formats

      Select *
      From Table1
      Order by convert(datetime,StupidVarcharDateField)

      Never underestimate the power of human stupidity RAH

      C 1 Reply Last reply
      0
      • T Thanusree Duth

        how the datetime is written in a particular order using sql function?datetime format which i used is Dec 2 2010 9:40:45:000PM Dec 02, 2010 11:59:59:000PM Dec 3 2010 3:45:54:000AM Dec 3 2010 1:24:23:000AM Dec 3 2010 12:15:27:000AM how these datetimes in a correct order?pls help me...:confused:

        M Offline
        M Offline
        Md Marufuzzaman
        wrote on last edited by
        #3

        convert(datetime,Field) that's it.

        Thanks Md. Marufuzzaman


        I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

        1 Reply Last reply
        0
        • M Mycroft Holmes

          So you have made the most basic error in data storage, you have stored your dates as varchar. You will have trouble until you reformat your data to datetime. Do it NOW! However this may work on those formats

          Select *
          From Table1
          Order by convert(datetime,StupidVarcharDateField)

          Never underestimate the power of human stupidity RAH

          C Offline
          C Offline
          Chris Meech
          wrote on last edited by
          #4

          Wow. You got my five for figuring out what the OP wanted. I read the post several times and was left scratching my head. :)

          Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

          M 1 Reply Last reply
          0
          • C Chris Meech

            Wow. You got my five for figuring out what the OP wanted. I read the post several times and was left scratching my head. :)

            Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

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

            Chris Meech wrote:

            was left scratching my head

            Been there many times, thankfully between the lot of us someone generally gets the idea the OP is trying to convey.

            Never underestimate the power of human stupidity RAH

            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