{"id":20,"date":"2008-03-25T11:47:21","date_gmt":"2008-03-25T18:47:21","guid":{"rendered":"http:\/\/shivdev.com\/blog\/2008\/03\/25\/date-arithmetic-in-sql\/"},"modified":"2011-05-06T07:26:09","modified_gmt":"2011-05-06T07:26:09","slug":"date-arithmetic-in-sql","status":"publish","type":"post","link":"http:\/\/shivdev.com\/blog\/2008\/03\/25\/date-arithmetic-in-sql\/","title":{"rendered":"Date Truncation in SQL Server"},"content":{"rendered":"<p>Need to trunc dates in SQL Server? Follow the examples below.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT DATEADD(HOUR, DATEDIFF(HOUR, 0, GETDATE()), 0)   -- 2008-03-25 10:00:00.000\r\nSELECT DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0)     -- 2008-03-25 00:00:00.000\r\nSELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0) -- 2008-03-01 00:00:00.000\r\nSELECT DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), 0)   -- 2008-01-01 00:00:00.000<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Need to trunc dates in SQL Server? Follow the examples below.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/20"}],"collection":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":1,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"predecessor-version":[{"id":188,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/20\/revisions\/188"}],"wp:attachment":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}