{"id":84,"date":"2007-02-06T14:56:16","date_gmt":"2007-02-06T19:56:16","guid":{"rendered":"http:\/\/stein.everybody.org\/brain\/sql-server-truncate-time-from-date\/"},"modified":"2011-03-10T10:57:30","modified_gmt":"2011-03-10T15:57:30","slug":"sql-server-truncate-time-from-date","status":"publish","type":"post","link":"https:\/\/jeremystein.com\/brain\/sql-server-truncate-time-from-date\/","title":{"rendered":"SQL Server &#8211; truncate time from Date"},"content":{"rendered":"<p>In T-SQL, the easiest way to truncate a DateTime field (to get the date with midnight as its time) is this:<\/p>\n<p>CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)<\/p>\n<p>But I&#8217;ve also seen it done this way:<\/p>\n<p>CONVERT(VARCHAR(10), GETDATE(), 111) &#8212; just treat this as a datetime<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In T-SQL, the easiest way to truncate a DateTime field (to get the date with midnight as its time) is this: CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME) But I&#8217;ve also seen it done this way: CONVERT(VARCHAR(10), GETDATE(), 111) &#8212; just treat this as a datetime<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-sql-server"],"_links":{"self":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":0,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"wp:attachment":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}