Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get current time of SQL server?
Forum Updated to NodeBB v4.3 + New Features

How to get current time of SQL server?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.9k Views 2 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.
  • L Offline
    L Offline
    lina
    wrote on 18 Feb 2017, 05:38 last edited by A Former User
    #1

    Hi,
    I create some tables in SQL server. I connect to these tables using a Qt program. Qt program run on a different PC from SQL server. I want to get time of the system which run SQL server management in the qt program. I have Date field in the tables but they are empty now. How can I initial them?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 18 Feb 2017, 06:40 last edited by
      #2

      @lina Did you find any specific SQL query which returns time?

      157

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 18 Feb 2017, 11:51 last edited by
        #3

        Hi
        Do you mean like this ?
        http://www.blackwasp.co.uk/SQLGetDate.aspx

        A Date field merely holds a date type. so unless you write to it from the client
        nothing is shown.

        L 1 Reply Last reply 18 Feb 2017, 19:52
        0
        • M mrjj
          18 Feb 2017, 11:51

          Hi
          Do you mean like this ?
          http://www.blackwasp.co.uk/SQLGetDate.aspx

          A Date field merely holds a date type. so unless you write to it from the client
          nothing is shown.

          L Offline
          L Offline
          lina
          wrote on 18 Feb 2017, 19:52 last edited by
          #4

          @mrjj

          Hi,
          yes, I use sql server management tool. the name of database is Doc and the table which has Date field named as archive.I'm new in sql server. where should I add the below code?
          -- Select the current local time
          **SELECT getdate()

          DECLARE @CurrentTime DATETIME
          SET @CurrentTime = getdate()
          PRINT @CurrentTime**

          M 1 Reply Last reply 19 Feb 2017, 09:01
          0
          • L lina
            18 Feb 2017, 19:52

            @mrjj

            Hi,
            yes, I use sql server management tool. the name of database is Doc and the table which has Date field named as archive.I'm new in sql server. where should I add the below code?
            -- Select the current local time
            **SELECT getdate()

            DECLARE @CurrentTime DATETIME
            SET @CurrentTime = getdate()
            PRINT @CurrentTime**

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 19 Feb 2017, 09:01 last edited by
            #5

            @lina
            Hi
            Its been some years since i used MS SQL so not sure about it.
            Links says " SQL Server Management Studio query window. "

            L 1 Reply Last reply 19 Feb 2017, 10:18
            2
            • M mrjj
              19 Feb 2017, 09:01

              @lina
              Hi
              Its been some years since i used MS SQL so not sure about it.
              Links says " SQL Server Management Studio query window. "

              L Offline
              L Offline
              lina
              wrote on 19 Feb 2017, 10:18 last edited by
              #6

              @mrjj
              thanks, it works.

              1 Reply Last reply
              1

              1/6

              18 Feb 2017, 05:38

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved