Collections:
Difference Between GETDATE() and GETUTCDATE() in SQL Server
What Is the Difference Between GETDATE() and GETUTCDATE() in SQL Server Transact-SQL?
✍: FYIcenter.com
The difference between GETDATE() and GETUTCDATE() is time zone number of the SQL Server machine. The tutorial exercise below gives you a good example:
DECLARE @local_time DATETIME;
DECLARE @gmt_time DATETIME;
SET @local_time = GETDATE();
SET @gmt_time = GETUTCDATE();
SELECT 'Server local time: '
+ CONVERT(VARCHAR(40),@local_time);
SELECT 'Server GMT time: '
+ CONVERT(VARCHAR(40),@gmt_time);
SELECT 'Server time zone: '
+ CONVERT(VARCHAR(40),
DATEDIFF(hour,@gmt_time,@local_time));
GO
Server local time: Jun 2 2007 10:06PM
Server GMT time: Jun 2 2007 4:21PM
Server time zone: 6
Note that the local time is from SQL server machine, not your local machine if you are connected to the server remotely. The local time is also adjusted by day-light savings.
⇒ Formatting Time Zone in +/-hh:mm Format in SQL Server
⇐ Getting Year, Month and Day Out of DATETIME Values in SQL Server
⇑ Date/Time Operations and Functions in SQL Server Transact-SQL
2017-02-14, 5090🔥, 0💬
Popular Posts:
Where to find answers to frequently asked questions on Conditional Statements and Loops in SQL Serve...
How To Use "IF ... ELSE IF ..." Statement Structures in SQL Server Transact-SQL? "IF ... ELSE IF ......
How To Install Oracle Database 10g XE in Oracle? To install 10g universal edition, double click, Ora...
How Fixed Length Strings Are Truncated and Padded in SQL Server Transact-SQL? When the length of the...
How To Install Oracle Database 10g XE in Oracle? To install 10g universal edition, double click, Ora...