{"id":6506,"date":"2013-11-03T00:00:36","date_gmt":"2013-11-03T00:00:36","guid":{"rendered":"http:\/\/craftydba.com\/?p=6506"},"modified":"2016-04-20T18:11:00","modified_gmt":"2016-04-20T18:11:00","slug":"datetime-functions-sysutcdatetime","status":"publish","type":"post","link":"https:\/\/craftydba.com\/?p=6506","title":{"rendered":"Date\/Time Functions \u2013 SYSUTCDATETIME()"},"content":{"rendered":"<p>I am going to carry on with my series of short articles or tidbits on Transaction SQL <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms186724.aspx\">date\/time functions<\/a>. <\/p>\n<p>Most, if not all, modern day computer systems collect data which contains dates and times.  <\/p>\n<p>Not only is it important to know when a sales order came in, but we should fulfill the request using some type of queue (<a href=\"http:\/\/en.wikipedia.org\/wiki\/LIFO_(computing)\">LIFO<\/a>).  If if was a stack (<a href=\"http:\/\/en.wikipedia.org\/wiki\/FIFO\">FIFO<\/a>) implementation, the first person may never get his order!<\/p>\n<p>I will be exploring functions that return the current system date and time in a defined data type format.  Some formats have more precision than others.  <\/p>\n<p>Today, I will be investigating the <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/bb630387.aspx\">SYSUTCDATETIME()<\/a> function.  This function takes does not take any arguments but returns a datetime2(7) data type.  The time is expressed in terms of UTC time.<\/p>\n<p>The example below is a sample call to the function.<\/p>\n<pre class=\"lang:TSQL theme:familiar mark:1,2-3\" title=\"date\/time function - sysutcdatetime()\">\r\n--\r\n-- Get system date\/time - function 3\r\n--\r\n\r\nSELECT SYSUTCDATETIME() AS CURRENT_DT3;\r\n\r\n<\/pre>\n<\/p>\n<p>The output from the test is listed below.<\/p>\n<pre class=\"lang:TSQL theme:epicgeeks\" title=\"output\">\r\noutput: \r\n\r\nCURRENT_DT3\r\n---------------------------\r\n2013-11-26 18:41:16.3658763\r\n\r\n<\/pre>\n<\/p>\n<p>In a nutshell, this function returns the current system date and time in datetime2(7) format.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am going to carry on with my series of short articles or tidbits on Transaction SQL date\/time functions. Most, if not all, modern day computer systems collect data which contains dates and times. Not only is it important to know when a sales order came in, but we should fulfill the request using some type of queue (LIFO). If if was a stack (FIFO) implementation, the first person may never get his order! I will be exploring functions that return the current system date and time in a defined&hellip;<\/p>\n","protected":false},"author":1,"featured_media":6486,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[814],"tags":[31,940,15,943,29],"class_list":["post-6506","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-very-short-articles","tag-database-developer","tag-date-time-functions","tag-john-f-miner-iii","tag-sysutcdatetime","tag-tsql"],"_links":{"self":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/6506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6506"}],"version-history":[{"count":0,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/6506\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/media\/6486"}],"wp:attachment":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}