{"id":2564,"date":"2018-06-16T22:40:40","date_gmt":"2018-06-17T05:40:40","guid":{"rendered":"https:\/\/database.guide\/?p=2564"},"modified":"2021-01-28T14:11:25","modified_gmt":"2021-01-28T04:11:25","slug":"getutcdate-examples-in-sql-server-t-sql","status":"publish","type":"post","link":"https:\/\/database.guide\/getutcdate-examples-in-sql-server-t-sql\/","title":{"rendered":"GETUTCDATE() Examples in SQL Server (T-SQL)"},"content":{"rendered":"<p>When using <a href=\"https:\/\/database.guide\/what-is-sql-server\/\">SQL Server<\/a>, you can use the <a href=\"https:\/\/database.guide\/what-is-t-sql\/\">T-SQL<\/a> <code>GETUTCDATE()<\/code> function to return\u00a0the current UTC time (Coordinated Universal Time). UTC time is the primary time standard by which the world regulates clocks and time.<\/p>\n<p>The return value of the <code>GETUTCDATE()<\/code> function is derived from the computer on which the instance of SQL Server is running. The time zone is not included, and it is returned as a\u00a0<strong>datetime<\/strong>\u00a0value.<\/p>\n<p><!--more--><\/p>\n<h2>Syntax<\/h2>\n<p>The syntax goes like this:<\/p>\n<pre>GETUTCDATE()<\/pre>\n<p>So it doesn&#8217;t accept any arguments.<\/p>\n<h2>Example<\/h2>\n<p>Here&#8217;s an example of usage:<\/p>\n<pre>SELECT GETUTCDATE() AS Result;<\/pre>\n<p>Result:<\/p>\n<pre>+-------------------------+\r\n| Result                  |\r\n|-------------------------|\r\n| 2018-06-17 05:17:46.750 |\r\n+-------------------------+<\/pre>\n<h2>Formatting the Date<\/h2>\n<p>You can always use other T-SQL functions along with <code>GETUTCDATE()<\/code>. For example, you can use the <code>FORMAT()<\/code> function to format the date into the format you require (and have it returned as a string).<\/p>\n<p>Example:<\/p>\n<pre>\u00a0\r\nSELECT FORMAT(GETUTCDATE(), 'dddd, dd MMMM yyyy, hh:mm tt') AS Result;\r\n<\/pre>\n<p>Result:<\/p>\n<pre>+--------------------------------+\r\n| Result                         |\r\n|--------------------------------|\r\n| Sunday, 17 June 2018, 05:43 AM |\r\n+--------------------------------+\r\n<\/pre>\n<p>Note that <code>GETUTCDATE()<\/code> has less fractional seconds precision than the <a href=\"https:\/\/database.guide\/sysutcdatetime-examples-in-sql-server-t-sql\/\"><code>SYSUTCDATETIME()<\/code><\/a> function, which returns the UTC date\/time as a <code>datetime2<\/code> value, with a fractional seconds precision range from 1 to 7 digits.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When using SQL Server, you can use the T-SQL GETUTCDATE() function to return\u00a0the current UTC time (Coordinated Universal Time). UTC time is the primary time standard by which the world regulates clocks and time. The return value of the GETUTCDATE() function is derived from the computer on which the instance of SQL Server is running. &#8230; <a title=\"GETUTCDATE() Examples in SQL Server (T-SQL)\" class=\"read-more\" href=\"https:\/\/database.guide\/getutcdate-examples-in-sql-server-t-sql\/\" aria-label=\"Read more about GETUTCDATE() Examples in SQL Server (T-SQL)\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,5],"tags":[68,115,93,77,61],"class_list":["post-2564","post","type-post","status-publish","format-standard","hentry","category-sql","category-sql-server","tag-date-functions","tag-dates","tag-functions","tag-mssql","tag-t-sql"],"_links":{"self":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/2564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/comments?post=2564"}],"version-history":[{"count":3,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/2564\/revisions"}],"predecessor-version":[{"id":2570,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/2564\/revisions\/2570"}],"wp:attachment":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/media?parent=2564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/categories?post=2564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/tags?post=2564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}