Search code examples
sqlsql-serversql-server-2005-express

How to get alone time 11:21 (highlighted in red) with SQL Server database?


Done automatically add the date to the time of the database SQL Server 2005 Express. So when you add a new record in the database is added automatically date and time in the form of:

Create Table Baza_test
(

   ID bigint IDENTITY (1,1) NOT NULL,
   Client nvarchar (23)
   address nvarchar (46)
   DateOfAddmission datetime default CURRENT_TIMESTAMP
   aaaaaadres nvarchar (46)

);

How to get alone time (highlighted in red):

enter image description here

with SQL Server database?


Solution

  • With the following query:

    select CONVERT(VARCHAR(5), DateOfAddmission,108) AS [time] from Baza_test where ID = 1;