User Id :    Password :      New Member   Forgot Password  
 
Get current zone time using GETUTCDATE() function in instance of SQL Server.
Description Sometime we need to get the current datetime of the system where the instance of SQL server(client) is running regadless of SQL server placed in other country or different time zone. Here I will explain how you can get local datetime where the client(instance of the SQL server) is running.   No. of Views     2448
  Rating     0
Author Najmul Hoda   Posted On     17 Feb 2012
Tags SQL SERVER    

Sample Code   Download Code

 

Sometime we need to get the current datetime of the system where the instance of SQL server(client) is running regadless of SQL server placed in other country or different time zone. In this situaltion if we use GETDATE() function it will give you server current datetime. But using GETUTCDATE() function you can get the current date of the client location where the instance of the SQL server is running.

 

SELECT 'SYSDATETIME()      ', SYSDATETIME();
SELECT 'SYSDATETIMEOFFSET()', SYSDATETIMEOFFSET();
SELECT 'SYSUTCDATETIME()   ', SYSUTCDATETIME();
SELECT 'CURRENT_TIMESTAMP  ', CURRENT_TIMESTAMP;
SELECT 'GETDATE()          ', GETDATE();
SELECT 'GETUTCDATE()       ', GETUTCDATE();
/* Returned:
SYSDATETIME()            2007-05-03 18:34:11.9351421
SYSDATETIMEOFFSET()      2007-05-03 18:34:11.9351421 -07:00
SYSUTCDATETIME()         2007-05-04 01:34:11.9351421
CURRENT_TIMESTAMP        2007-05-03 18:34:11.933
GETDATE()                2007-05-03 18:34:11.933
GETUTCDATE()             2007-05-04 01:34:11.933

About Author

About Author He is a team lead, having 8+ years of experience. He loves writing technical article for .Net developers. Najmul Hoda
No Photo
 
Country United States
Company BirlaSoft
Home Page http://www.magixchat.com

Rate this article

Rating options from poor, fair, good, very good to excelent.  
 

Comments

   
Write your comment here.
Comment
Verification Code