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?
Qt 6.11 is out! See what's new in the release blog

How to get current time of SQL server?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 2.3k 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.
  • linaL Offline
    linaL Offline
    lina
    wrote on 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
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

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

      157

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on 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.

        linaL 1 Reply Last reply
        0
        • mrjjM mrjj

          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.

          linaL Offline
          linaL Offline
          lina
          wrote on 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**

          mrjjM 1 Reply Last reply
          0
          • linaL lina

            @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**

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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. "

            linaL 1 Reply Last reply
            2
            • mrjjM mrjj

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

              linaL Offline
              linaL Offline
              lina
              wrote on last edited by
              #6

              @mrjj
              thanks, it works.

              1 Reply Last reply
              1

              • Login

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