0

How to get the current system time only in SQL Server / any database.

The date is not required...only the current time is required.

Taryn
  • 242,637
  • 56
  • 362
  • 405
Gallop
  • 1,365
  • 3
  • 16
  • 28
  • Please have a look [Get Date and Time From Current DateTime](http://blog.sqlauthority.com/2012/09/12/sql-server-get-date-and-time-from-current-datetime-sql-in-sixty-seconds-025-video/) – huMpty duMpty Nov 23 '12 at 11:41

4 Answers4

4

You can use getdate() or current_timestamp

This will give you both date and time but then you can format it however you need.

If you are using SQL Server 2008+ you can even format the result as time:

 select cast(getdate() as time)

If you are not in SQL Server 2008+, then you can use many different methods to get the time only including:

 SELECT convert(char(8), getdate(), 108)

See SQL fiddle demo with several versions

Taryn
  • 242,637
  • 56
  • 362
  • 405
0
Using `getdate()` like:
    select getdate()
=============================

and get only time use convert function with 108 code like :
  select convert(varchar,GETDATE(),108)
Vikram Jain
  • 5,498
  • 1
  • 19
  • 31
0

select CONVERT(VARCHAR(8),GETDATE(),108) CurrTime;

Deniyal Tandel
  • 512
  • 3
  • 14
0

There is 3 different statement available to get the current system time

select CONVERT(VARCHAR(8),getDate(),108)

select CONVERT(VARCHAR(8),{fn NOW()},108)

select CONVERT(VARCHAR(8),CURRENT_TIMESTAMP,108)

They all produce the same results and performance are the same, therefore it is really whatever one of the three you prefer the look of.