SQL SERVER – 2008 – Get Current System Date Time

How to get current system date time in SQL Server?

First thing which comes to many users is using following script.

SELECT GETDATE() AS CurrentDateTime

Above method is not the only method to retrieve the current system date time for SQL Server. SQL Server 2008 has many different function which provides current system date time in different format and little difference in details.

SELECT 'SYSDATETIME' AS FunctionName, SYSDATETIME() AS DateTimeFormat
UNION ALL
SELECT 'SYSDATETIMEOFFSET', SYSDATETIMEOFFSET()
UNION ALL
SELECT 'SYSUTCDATETIME', SYSUTCDATETIME()
UNION ALL
SELECT 'CURRENT_TIMESTAMP', CURRENT_TIMESTAMP
UNION ALL
SELECT 'GETDATE', GETDATE()
UNION ALL
SELECT 'GETUTCDATE', GETUTCDATE()

In SQL Server 2008, use any of the above function depending on your need.

SQL SERVER - 2008 - Get Current System Date Time datetime2008

Quick Video on the same subject

Reference : Pinal Dave (https://blog.sqlauthority.com)

, , ,
Previous Post
SQL SERVER – 2008 – Find Current System Date Time and Time Offset
Next Post
SQL SERVER – Effect of Order of Join In Query

Related Posts

39 Comments. Leave new

  • i want a qurey that minus system date and my date in data base like i want to use it on searching select * from emp where systemdate-mydate>=120days
    can you plz tell me the qurey for that i am confused how to minus sysdate and mydate
    mydate is my column name kindly mail me the solution

    Reply
  • Hi,i made databse is in vusualstudio 2010 i want to get date automatically from my system without entering date manually in text box.i need to get date automatically from system and store it in databse with other enteries……………….
    please tell me how to do it???????

    Reply
  • Thanks for this post. I didn’t get a chance yet to work on SQL Server 2008 or above. Should try it in future.

    Reply
  • SELECT ‘FUNCTION’,CAST( {fn NOW()} AS DATETIME)
    SELECT ‘FUNCTION’,CAST( GETDATE() AS DATETIME)

    Reply
  • How to get system’s date format using sql statement?

    Reply
  • hello sir this is chandru i have developed chit fund software i need to make autoupdated when purticular date changed to next date kindly help me sir

    Reply
  • i am not understand

    Reply

Leave a Reply

Menu