{"id":176,"date":"2012-04-24T10:04:55","date_gmt":"2012-04-24T10:04:55","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2012\/04\/24\/sql-server-convert-string-to-date-mm-dd-yyyy\/"},"modified":"2012-04-24T10:04:55","modified_gmt":"2012-04-24T10:04:55","slug":"sql-server-convert-string-to-date-mm-dd-yyyy","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2012\/04\/24\/sql-server-convert-string-to-date-mm-dd-yyyy\/","title":{"rendered":"sql server convert string to date mm dd yyyy"},"content":{"rendered":"

Below script converts string(varchar) to date. Date value in string can be in the format mm\/dd\/yy (or) mm-dd-yyyy
\n[sql]
\n–mm\/dd\/yyyy
\nSELECT CAST(’12\/30\/2000′ AS DATE)
\n–mm-dd-yyyy using cast
\nSELECT CAST(’12-30-2000′ AS DATE)<\/p>\n

–mm\/dd\/yyyy using cast
\nSELECT CONVERT(date,’12\/30\/2000′)
\n–mm-dd-yyyy using cast
\nSELECT CONVERT(date,’12-30-2000′)
\n[\/sql]<\/p>\n","protected":false},"excerpt":{"rendered":"

Below script converts string(varchar) to date. Date value in string can be in the format mm\/dd\/yy (or) mm-dd-yyyy [sql] –mm\/dd\/yyyy SELECT CAST(’12\/30\/2000′ AS DATE) –mm-dd-yyyy using cast SELECT CAST(’12-30-2000′ AS DATE) –mm\/dd\/yyyy using cast SELECT CONVERT(date,’12\/30\/2000′) –mm-dd-yyyy using cast SELECT CONVERT(date,’12-30-2000′) [\/sql]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[1795,1796,1797,1798,1799],"class_list":["post-176","post","type-post","status-publish","format-standard","hentry","category-sql-server-basics","tag-convert-string-to-date-mm-dd-yyyy-sql-server","tag-convert-string-to-date-mm-dd-yyyy-sql-server-2008","tag-convert-string-to-date-mm-dd-yyyy-sql-server-2012","tag-how-to-convert-string-in-mm-dd-yy-format-to-date-in-sql-server","tag-sql-server-convert-varchar-to-date-mm-dd-yyyy"],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/comments?post=176"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/176\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}