{"id":9707,"date":"2018-11-23T08:03:10","date_gmt":"2018-11-23T10:03:10","guid":{"rendered":"http:\/\/www.fabriciolima.net\/?p=9707"},"modified":"2019-04-17T14:36:45","modified_gmt":"2019-04-17T17:36:45","slug":"managed-instance-7-a-funcao-getdate-ja-retorna-a-data-da-minha-localidade","status":"publish","type":"post","link":"https:\/\/fabriciolima.net\/blog\/2018\/11\/23\/managed-instance-7-a-funcao-getdate-ja-retorna-a-data-da-minha-localidade\/","title":{"rendered":"Managed Instance (#7) &#8211; A fun\u00e7\u00e3o getdate() j\u00e1 retorna a data da minha localidade?"},"content":{"rendered":"<p>Fala Pessoal,<\/p>\n<p>Esse \u00e9 mais um post da s\u00e9rie sobre o Azure SQL Database Managed Instance. Caso ainda n\u00e3o tenha visto, seguem os posts anteriores:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.fabriciolima.net\/blog\/2018\/03\/17\/azure-sql-db-managed-instance-introducao\/https:\/\/www.fabriciolima.net\/blog\/2018\/11\/16\/managed-instance-criando-minha-primeira-instancia\/\" target=\"_blank\" rel=\"noopener\">Azure SQL DB Managed Instance \u2013 Introdu\u00e7\u00e3o<\/a><\/li>\n<li><a href=\"https:\/\/www.fabriciolima.net\/blog\/2018\/11\/16\/managed-instance-criando-minha-primeira-instancia\/\" target=\"_blank\" rel=\"noopener\">Managed Instance \u2013 Criando minha primeira inst\u00e2ncia<\/a><\/li>\n<li><a href=\"https:\/\/www.fabriciolima.net\/blog\/2018\/11\/19\/managed-instance-como-se-conectar-direto-do-ssms-utilizando-uma-vpn\/\" target=\"_blank\" rel=\"noopener\">Managed Instance \u2013 Como se conectar direto do SSMS utilizando uma VPN?<\/a><\/li>\n<li><a href=\"https:\/\/www.fabriciolima.net\/blog\/2018\/11\/20\/managed-instance-como-se-conectar-atraves-do-ssms-de-uma-vm-do-azure\/\" target=\"_blank\" rel=\"noopener\">Managed Instance \u2013 Como se conectar atrav\u00e9s do SSMS de uma VM do Azure?<\/a><\/li>\n<li><a href=\"https:\/\/www.fabriciolima.net\/blog\/2018\/11\/21\/managed-instance-5-quanto-custa-tudo-isso\/\" target=\"_blank\" rel=\"noopener\">Managed Instance (#5) &#8211; Quanto custa tudo isso?<\/a><\/li>\n<li><a href=\"https:\/\/www.fabriciolima.net\/blog\/2018\/11\/22\/managed-instance-6-consigo-fazer-um-join-entre-tabelas-de-bases-diferentes\/\" target=\"_blank\" rel=\"noopener\">Managed Instance (#6) &#8211; Consigo fazer um Join entre tabelas de bases diferentes?<\/a><\/li>\n<\/ul>\n<p>Em Julho de 2018 eu fiz um post sobre o valor retornado pela fun\u00e7\u00e3o Getdate() no Azure SQL Database:<\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2018\/07\/10\/azure-sql-database-funcao-getdate-com-valor-errado-no-azure-e-isso-mesmo\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.fabriciolima.net\/blog\/2018\/07\/10\/azure-sql-database-funcao-getdate-com-valor-errado-no-azure-e-isso-mesmo\/<\/a><\/p>\n<p>Assim como o Azure SQL Database, no momento que esse post est\u00e1 sendo escrito (18\/11\/2018), o Managed Instance ainda utiliza o\u00a0UTC como\u00a0time zone para suas inst\u00e2ncias.<\/p>\n<p>Segue comprova\u00e7\u00e3o abaixo:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-9709 aligncenter\" src=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_1.png\" alt=\"\" width=\"702\" height=\"564\" srcset=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_1.png 974w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_1-300x241.png 300w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_1-768x617.png 768w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_1-700x562.png 700w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_1-410x329.png 410w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_1-100x80.png 100w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_1-275x221.png 275w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_1-20x16.png 20w\" sizes=\"auto, (max-width: 702px) 100vw, 702px\" \/><\/p>\n<p>Minha hora local \u00e9 <strong>14:18hs<\/strong> e o getdate() retorna <strong>16:18hs<\/strong>.<\/p>\n<p>A solu\u00e7\u00e3o atual seria criar uma fun\u00e7\u00e3o getdate2() como fiz no meu post do Azure SQL Database:<\/p>\n<pre class=\"lang:tsql decode:true \">CREATE FUNCTION dbo.getdate2()\r\nRETURNS datetime\r\nWITH SCHEMABINDING\r\nAS\r\nbegin\r\nDECLARE @getdate datetime\r\nSET @getdate = SYSDATETIMEOFFSET() AT TIME ZONE 'E. South America Standard Time'\r\nRETURN @getdate\r\nend<\/pre>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-9708 aligncenter\" src=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_2.png\" alt=\"\" width=\"660\" height=\"521\" srcset=\"https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_2.png 883w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_2-300x237.png 300w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_2-768x606.png 768w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_2-700x553.png 700w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_2-410x324.png 410w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_2-100x79.png 100w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_2-275x217.png 275w, https:\/\/fabriciolima.net\/blog\/wp-content\/uploads\/2018\/11\/Managedinstance_Getdate_2-20x16.png 20w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/p>\n<p>Caso use getdate() no seu ambiente, ter\u00e1 que fazer um replace no seu c\u00f3digo pela fun\u00e7\u00e3o getdate2() para fazer essa migra\u00e7\u00e3o.<\/p>\n<p>Mas, Por\u00e9m, Entretanto, Contudo, Todavia&#8230;. Na palestra do <strong>Borko Novakovic<\/strong> (l\u00edder do projeto MI) no Pass Summit 2018, ele disse que est\u00e1 vindo em breve a possibilidade de utilizar nosso Time Zone local na cria\u00e7\u00e3o de um MI.<\/p>\n<p>\u00d3tima not\u00edcia.<\/p>\n<p>Quando sair, atualizo esse post com essa informa\u00e7\u00e3o.<\/p>\n<p><span style=\"color: #ff0000;\"><strong>**** Atualizado dia 17\/04\/2019 ****<\/strong><\/span><\/p>\n<p>Esse problema j\u00e1 foi solucionado conforme detalhei no post abaixo:<\/p>\n<p><a href=\"https:\/\/www.fabriciolima.net\/blog\/2019\/04\/17\/managed-instance-21-problema-do-getdate-na-sua-localidade-resolvido\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.fabriciolima.net\/blog\/2019\/04\/17\/managed-instance-21-problema-do-getdate-na-sua-localidade-resolvido\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><b>Gostou dessa Dica?<\/b><\/p>\n<p>Curta, comente, compartilhe\u2026<\/p>\n<p>Assine meu canal no\u00a0<a class=\"external-link wpel-icon-left\" href=\"https:\/\/www.youtube.com\/channel\/UCeBRAO_LLrUdSrOXIywjzRA\" target=\"_blank\" rel=\"nofollow external noopener noreferrer\" data-wpel-link=\"external\">Youtube<\/a>\u00a0, curta minha p\u00e1gina no\u00a0<a class=\"external-link wpel-icon-left\" href=\"https:\/\/www.facebook.com\/FabricioLimaSolucoesemBancodeDados\/\" target=\"_blank\" rel=\"external noopener noreferrer nofollow\" data-wpel-link=\"external\">Facebook<\/a>\u00a0 ou siga nossa p\u00e1gina no <a href=\"https:\/\/www.instagram.com\/fabriciolimasolucoesembd\" target=\"_blank\" rel=\"noopener\">Instagram<\/a> para receber Dicas de Leituras, V\u00eddeos e Eventos sobre SQL Server.<\/p>\n<p>At\u00e9 o pr\u00f3ximo post.<\/p>\n<p>Abra\u00e7os,<\/p>\n<p>Fabr\u00edcio Lima<\/p>\n<p>Microsoft Data Platform MVP<\/p>\n<p>Consultor e Instrutor SQL Server<\/p>\n<p>Trabalha com SQL Server desde 2006<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fala Pessoal, Esse \u00e9 mais um post da s\u00e9rie sobre o Azure SQL Database Managed Instance. Caso ainda n\u00e3o tenha visto, seguem os posts anteriores: Azure SQL DB Managed Instance \u2013 Introdu\u00e7\u00e3o Managed Instance \u2013 Criando minha primeira inst\u00e2ncia Managed Instance \u2013 Como se conectar direto do SSMS utilizando uma VPN? Managed Instance \u2013 Como [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[1616,1617,1512,280],"tags":[1641],"class_list":["post-9707","post","type-post","status-publish","format-standard","hentry","category-azure-sql-database","category-managed-instance","category-sql-azure","category-virtual-pass-br","tag-azure"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/9707","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/comments?post=9707"}],"version-history":[{"count":8,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/9707\/revisions"}],"predecessor-version":[{"id":10463,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/posts\/9707\/revisions\/10463"}],"wp:attachment":[{"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/media?parent=9707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/categories?post=9707"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fabriciolima.net\/blog\/wp-json\/wp\/v2\/tags?post=9707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}