{"id":175,"date":"2012-04-24T09:56:43","date_gmt":"2012-04-24T09:56:43","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2012\/04\/24\/sql-server-convert-string-to-date-yyyymmdd\/"},"modified":"2012-04-24T09:56:43","modified_gmt":"2012-04-24T09:56:43","slug":"sql-server-convert-string-to-date-yyyymmdd","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2012\/04\/24\/sql-server-convert-string-to-date-yyyymmdd\/","title":{"rendered":"sql server convert string to date yyyymmdd"},"content":{"rendered":"
You can use cast or convert to convert string which is in yyyy\/mm\/dd (or) yyyy-mm-dd format to date.<\/p>\n
Below is the script:
\n[sql]
\n–yyyy\/mm\/dd using cast
\nSELECT CAST(‘2000\/12\/30’ AS DATE)
\n–yyyy-mm-dd using cast
\nSELECT CAST(‘2000-12-30′ AS DATE)<\/p>\n
–yyyy\/mm\/dd using cast
\nSELECT CONVERT(date,’2000\/12\/30′)
\n–yyyy-mm-dd using cast
\nSELECT CONVERT(date,’2000-12-30’)
\n[\/sql]<\/p>\n","protected":false},"excerpt":{"rendered":"
You can use cast or convert to convert string which is in yyyy\/mm\/dd (or) yyyy-mm-dd format to date. Below is the script: [sql] –yyyy\/mm\/dd using cast SELECT CAST(‘2000\/12\/30’ AS DATE) –yyyy-mm-dd using cast SELECT CAST(‘2000-12-30′ AS DATE) –yyyy\/mm\/dd using cast SELECT CONVERT(date,’2000\/12\/30′) –yyyy-mm-dd using cast SELECT CONVERT(date,’2000-12-30’) [\/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":[1792,1793,1794],"class_list":["post-175","post","type-post","status-publish","format-standard","hentry","category-sql-server-basics","tag-convert-string-to-date-yyyymmdd","tag-convert-string-to-date-yyyymmdd-sql-server-2008","tag-convert-string-to-date-yyyymmdd-sql-server-2012"],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/175","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=175"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/175\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}