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. Other Discussions
  3. The Weird and The Wonderful
  4. Get the date from SQL Server

Get the date from SQL Server

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasesql-serversysadminworkspace
9 Posts 8 Posters 2 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.
  • A Offline
    A Offline
    Alex Baker
    wrote on last edited by
    #1

    I am currently moving a powerbuilder application from a SQL server 2000 environment to SQL 2005. Easy you would think until I discovered the code was full of this sort of thing select getdate() from sysobjects where id=1 simply to get the current date / time!! In SQL 2005 sysobjects does exist as a compatibility view however the data in it does not contain a record with an id of 1... the application fails in a big way..

    Alex Baker

    R P S M G 5 Replies Last reply
    0
    • A Alex Baker

      I am currently moving a powerbuilder application from a SQL server 2000 environment to SQL 2005. Easy you would think until I discovered the code was full of this sort of thing select getdate() from sysobjects where id=1 simply to get the current date / time!! In SQL 2005 sysobjects does exist as a compatibility view however the data in it does not contain a record with an id of 1... the application fails in a big way..

      Alex Baker

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

      nasty! did the original programmer not realise that select getdate() would work too?

      "An eye for an eye only ends up making the whole world blind"

      1 Reply Last reply
      0
      • A Alex Baker

        I am currently moving a powerbuilder application from a SQL server 2000 environment to SQL 2005. Easy you would think until I discovered the code was full of this sort of thing select getdate() from sysobjects where id=1 simply to get the current date / time!! In SQL 2005 sysobjects does exist as a compatibility view however the data in it does not contain a record with an id of 1... the application fails in a big way..

        Alex Baker

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Looks kinda Oracle-ish -- it could be Oracle ported to SQL Server... badly. I worked for a company that had always used Oracle (on OpenVMS), but one customer wanted SQL Server (6) (on WinNT) so a bunch of PowerBuilder idiots were brought in to write some of the worst code I've ever seen. Data access in the UI?! X|

        1 Reply Last reply
        0
        • A Alex Baker

          I am currently moving a powerbuilder application from a SQL server 2000 environment to SQL 2005. Easy you would think until I discovered the code was full of this sort of thing select getdate() from sysobjects where id=1 simply to get the current date / time!! In SQL 2005 sysobjects does exist as a compatibility view however the data in it does not contain a record with an id of 1... the application fails in a big way..

          Alex Baker

          S Offline
          S Offline
          supercat9
          wrote on last edited by
          #4

          The wonderful thing about standards is that there are so many of them. If I recall, I create a variable (in vb.net) with the name of the SQL get-date function, and then I use that. I forget how I set it, but it was something pretty clunky like "If database type looks like SQL Server, set it to GETDATE() otherwise set to NOW()".

          I 1 Reply Last reply
          0
          • S supercat9

            The wonderful thing about standards is that there are so many of them. If I recall, I create a variable (in vb.net) with the name of the SQL get-date function, and then I use that. I forget how I set it, but it was something pretty clunky like "If database type looks like SQL Server, set it to GETDATE() otherwise set to NOW()".

            I Offline
            I Offline
            irol
            wrote on last edited by
            #5

            Hello, How to get miliseconds form MS SQL Server using ADO and C++ ? COleDateTime doesn't support miliseconds ... Best Regards, Irek

            M 1 Reply Last reply
            0
            • A Alex Baker

              I am currently moving a powerbuilder application from a SQL server 2000 environment to SQL 2005. Easy you would think until I discovered the code was full of this sort of thing select getdate() from sysobjects where id=1 simply to get the current date / time!! In SQL 2005 sysobjects does exist as a compatibility view however the data in it does not contain a record with an id of 1... the application fails in a big way..

              Alex Baker

              M Offline
              M Offline
              MaksimP
              wrote on last edited by
              #6

              --You can use 'set' instead of 'select' declare @t as DateTime set @t = getUtcDate() -- Testing-- print @t print DatePart(hh,@t) print DatePart(mm,@t) print DatePart(ss,@t) print DatePart(ms,@t)

              1 Reply Last reply
              0
              • I irol

                Hello, How to get miliseconds form MS SQL Server using ADO and C++ ? COleDateTime doesn't support miliseconds ... Best Regards, Irek

                M Offline
                M Offline
                MaksimP
                wrote on last edited by
                #7

                You can do it sql by using 'DatePart(ms,<dbColumnTime>)' function

                1 Reply Last reply
                0
                • A Alex Baker

                  I am currently moving a powerbuilder application from a SQL server 2000 environment to SQL 2005. Easy you would think until I discovered the code was full of this sort of thing select getdate() from sysobjects where id=1 simply to get the current date / time!! In SQL 2005 sysobjects does exist as a compatibility view however the data in it does not contain a record with an id of 1... the application fails in a big way..

                  Alex Baker

                  G Offline
                  G Offline
                  Gordon Kushner
                  wrote on last edited by
                  #8

                  If I remember right, I think Oracle programmers had to do something like SELECT "Hello World" FROM DUAL because it wouldn't allow a SELECT without a FROM. Could be a recent convert.

                  J 1 Reply Last reply
                  0
                  • G Gordon Kushner

                    If I remember right, I think Oracle programmers had to do something like SELECT "Hello World" FROM DUAL because it wouldn't allow a SELECT without a FROM. Could be a recent convert.

                    J Offline
                    J Offline
                    Jane Williams
                    wrote on last edited by
                    #9

                    You do remember right, and I was trying to forget.

                    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