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. how to change timestamp of a DB in SQL Server 2005?

how to change timestamp of a DB in SQL Server 2005?

Scheduled Pinned Locked Moved Database
databasesql-serversysadmintutorialquestion
10 Posts 2 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.
  • A Offline
    A Offline
    alexyxj
    wrote on last edited by
    #1

    Can anyone tell me how to change time for a DB in SQL Server 2005? I need to correct the time for a database, thanks.

    W 1 Reply Last reply
    0
    • A alexyxj

      Can anyone tell me how to change time for a DB in SQL Server 2005? I need to correct the time for a database, thanks.

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      You set the time of the windows server.

      A 1 Reply Last reply
      0
      • W Wendelius

        You set the time of the windows server.

        A Offline
        A Offline
        alexyxj
        wrote on last edited by
        #3

        so you mean the database will use the time of windows server. my issue is for a specific database, say DB002, I wanna change its current time setting (set its current time 01-01-2006), can I do that?

        W 1 Reply Last reply
        0
        • A alexyxj

          so you mean the database will use the time of windows server. my issue is for a specific database, say DB002, I wanna change its current time setting (set its current time 01-01-2006), can I do that?

          W Offline
          W Offline
          Wendelius
          wrote on last edited by
          #4

          SQL Server uses windows clock which then again uses clock from BIOS. So you can have only one time at the server which is the time of all databases. I don't know what happens if you set up a virtual PC. Since virtual PC has emulated bios it could be possible to have "several times" on one physical server. But... this is just a guess.

          A 1 Reply Last reply
          0
          • W Wendelius

            SQL Server uses windows clock which then again uses clock from BIOS. So you can have only one time at the server which is the time of all databases. I don't know what happens if you set up a virtual PC. Since virtual PC has emulated bios it could be possible to have "several times" on one physical server. But... this is just a guess.

            A Offline
            A Offline
            alexyxj
            wrote on last edited by
            #5

            maybe we got into a wrong direction. let me clarify this issue. in one of my databases, I have some tables having timestamp columns, now I just wanna change displayed time for those columns. Can I just use some scripts like: update TABLE ** set **=getdate()

            W 1 Reply Last reply
            0
            • A alexyxj

              maybe we got into a wrong direction. let me clarify this issue. in one of my databases, I have some tables having timestamp columns, now I just wanna change displayed time for those columns. Can I just use some scripts like: update TABLE ** set **=getdate()

              W Offline
              W Offline
              Wendelius
              wrote on last edited by
              #6

              Sorry, I misunderstood you. Is the column's data type timestamp? Timestamp-typed columns cannot be modified via DML. Moreover they are not timestamps, but only unique identifiers that database engine update.

              A 1 Reply Last reply
              0
              • W Wendelius

                Sorry, I misunderstood you. Is the column's data type timestamp? Timestamp-typed columns cannot be modified via DML. Moreover they are not timestamps, but only unique identifiers that database engine update.

                A Offline
                A Offline
                alexyxj
                wrote on last edited by
                #7

                data type for the column is 'datetime', column name could be anything.

                W 1 Reply Last reply
                0
                • A alexyxj

                  data type for the column is 'datetime', column name could be anything.

                  W Offline
                  W Offline
                  Wendelius
                  wrote on last edited by
                  #8

                  If it's datetime then you can simply set a desired date to the column:

                  UPDATE TableName SET DateTimeColumn = CONVERT(datetime, '01/01/2006', 101) ...

                  which will use midnight for time portion or you can use current date and subtract desired amount of days like:

                  UPDATE TableName SET DateTimeColumn = GETDATE() - 975 ...

                  which will today end up to 01/01/2006, but using current time FYI, if the column name would be timestamp, it is hardcoded to many libraries that is must have timestamp as data type. This will lead to problems in some cases (typically in cursor handling) if the actual datatype isn't timestamp.

                  A 1 Reply Last reply
                  0
                  • W Wendelius

                    If it's datetime then you can simply set a desired date to the column:

                    UPDATE TableName SET DateTimeColumn = CONVERT(datetime, '01/01/2006', 101) ...

                    which will use midnight for time portion or you can use current date and subtract desired amount of days like:

                    UPDATE TableName SET DateTimeColumn = GETDATE() - 975 ...

                    which will today end up to 01/01/2006, but using current time FYI, if the column name would be timestamp, it is hardcoded to many libraries that is must have timestamp as data type. This will lead to problems in some cases (typically in cursor handling) if the actual datatype isn't timestamp.

                    A Offline
                    A Offline
                    alexyxj
                    wrote on last edited by
                    #9

                    THANKS Mika

                    W 1 Reply Last reply
                    0
                    • A alexyxj

                      THANKS Mika

                      W Offline
                      W Offline
                      Wendelius
                      wrote on last edited by
                      #10

                      You're welcome

                      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