{"id":29319,"date":"2023-11-20T05:16:00","date_gmt":"2023-11-20T04:16:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=29319"},"modified":"2023-11-23T11:43:28","modified_gmt":"2023-11-23T10:43:28","slug":"convert-string-to-date-in-sql-server","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/","title":{"rendered":"How to convert a string to a date format in SQL Server ?"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\" id=\"h-different-solutions-to-convert-a-date-stored-in-a-text-to-a-date-format-using-t-sql-functions\"><em>Different solutions to convert a date stored in a text to a date format using T-SQL functions.<\/em><\/h4>\n\n\n\n<p>When working with data in SQL Server, you may encounter situations where you must convert dates that are stored as strings to native date format of SQL. To perform meaningful date-based operations, it&#8217;s crucial to convert these strings into proper date data types. In this blog post, we&#8217;ll explore various methods to convert a string to a date in SQL Server, complete with code examples.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-1-use-implicit-or-explicit-methods-to-convert-a-string-to-date-format\">1. Use implicit or explicit methods to convert a string to date format<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-convert-sql-server-string-implicitly\"><em>Convert SQL Server string implicitly<\/em><\/h3>\n\n\n\n<p>Implicit string-to-date conversion occurs automatically without the need for specific functions. SQL Server relies on the string&#8217;s format and the default language settings for this type of conversion. If the string follows <a href=\"https:\/\/www.iso.org\/iso-8601-date-and-time-format.html\" target=\"_blank\" rel=\"noreferrer noopener\">ISO<\/a> formats like <em>yyyyMMdd<\/em> or <em>yyyy-MM-ddTHH:mm:ss(.mmm)<\/em>, it can be converted regardless of regional settings.<\/p>\n\n\n\n<p>However, unsupported formats will result in an exception. So the implicit conversion is not recomended. Let&#8217;s consider a basic example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT *\nFROM   dbo.Sales\nWHERE  DateAsString = '20230115';\n<\/pre>\n\n\n\n<p>In this case, the &#8216;20230115&#8217; string will be implicitly converted to a date if the format matches the system&#8217;s settings.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-convert-sql-server-string-explicitly\"><em>Convert SQL Server string explicitly<\/em><\/h3>\n\n\n\n<p>Explicit string-to-date conversion provides more control over the process and is achieved using functions like: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CAST()<\/li>\n\n\n\n<li>CONVERT()<\/li>\n\n\n\n<li>and PARSE().<\/li>\n<\/ul>\n\n\n\n<p>Moreover, these functions are particularly useful when <strong>dealing with non-standard date formats<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-2-convert-a-date-using-the-cast-function\">2. Convert a date using the CAST function<\/h2>\n\n\n\n<p>The <code>CAST()<\/code> function allows you to convert a string to a date by specifying the data type.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DECLARE @DateString VARCHAR(10) = '2023-01-15';\nDECLARE @DateValue  DATE;\n\nSET @DateValue = CAST(@DateString AS DATE);\n<\/pre>\n\n\n\n<p>In this example, we declare a string variable @DateString and use CAST() to convert it to a DATE data type.<\/p>\n\n\n\n<p><strong>Read also: <a href=\"https:\/\/expert-only.com\/en\/t-sql\/calculate-difference-between-two-dates\/\">Calculate the difference between two dates in T-SQL<\/a><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-3-use-the-convert-sql-server-function-to-transform-a-date\">3. Use the CONVERT SQL Server function to transform a date<\/h2>\n\n\n\n<p>The <code>CONVERT()<\/code> function offers more flexibility as you can specify both the desired data type and the style for the conversion.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DECLARE @DateString VARCHAR(10) = '01\/15\/2023';\nDECLARE @DateValue DATE;\n\n-- Explicitly use style 101 for mm\/dd\/yyyy format\nSET @DateValue = CONVERT(DATE, @DateString, 101);\n<\/pre>\n\n\n\n<p>In this example, we use CONVERT() with style 101 to convert the string &#8217;01\/15\/2023&#8242; to a <code>DATE<\/code> data type.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-medium\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"120\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2023\/11\/time-time-management-stopwatch-3216252-300x120.jpg\" alt=\"Use T-SQL functions to convert a string to a SQL Server date format \" class=\"wp-image-29337\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2023\/11\/time-time-management-stopwatch-3216252-300x120.jpg 300w, https:\/\/expert-only.com\/wp-content\/uploads\/2023\/11\/time-time-management-stopwatch-3216252-1024x410.jpg 1024w, https:\/\/expert-only.com\/wp-content\/uploads\/2023\/11\/time-time-management-stopwatch-3216252-768x307.jpg 768w, https:\/\/expert-only.com\/wp-content\/uploads\/2023\/11\/time-time-management-stopwatch-3216252.jpg 1280w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption class=\"wp-element-caption\"><em>Use T-SQL functions to convert a string to a SQL Server date format <\/em><\/figcaption><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-4-use-the-parse-conversion-option\">4. Use the PARSE conversion option<\/h2>\n\n\n\n<p>The <code>PARSE()<\/code> function, when combined with a culture parameter, allows you to convert strings with specific date formats.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DECLARE @DateString VARCHAR(10) = '15\/01\/2023';\nDECLARE @DateValue DATE;\n\n-- Using the 'en-US' culture for dd\/MM\/yyyy format\nSET @DateValue = PARSE(@DateString AS DATE USING 'en-US');\n<\/pre>\n\n\n\n<p>Here, we specify the culture as &#8216;en-US&#8217; to ensure correct conversion of the &#8217;15\/01\/2023&#8242; string.<\/p>\n\n\n\n<p><strong>Read also: <a href=\"https:\/\/expert-only.com\/en\/t-sql\/display-month-name-sql-server\/\">How to display month name in SQL Server?<\/a><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-5-using-the-format-function\">5. Using the FORMAT function<\/h2>\n\n\n\n<p>You can use the FORMAT() function to convert a string to a date by specifying the format explicitly. This method provides control over the input format. Please find an example below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DECLARE @DateString VARCHAR(10) = '01\/15\/2023';\nDECLARE @DateValue DATE;\n\nSET @DateValue = FORMAT(CONVERT(DATETIME, @DateString, 101), 'MM\/dd\/yyyy');\n\n-- @DateValue will contain the date '2023-01-15'\n<\/pre>\n\n\n\n<p>Moreover the FORMAT and CONVERT combination is a widely used technique to convert text to date.<\/p>\n\n\n\n<p>In this example, we start with a string called @DateString holding the date &#8217;01\/15\/2023&#8242;. To turn it into a date that computers can understand, we use the CONVERT function, which changes the string into a DATETIME value, taking note of the format &#8216;mm\/dd\/yyyy&#8217;.<\/p>\n\n\n\n<p>Next, we use the FORMAT() function to make sure it looks like &#8216;MM\/dd\/yyyy&#8217;. Finally, the result is saved in the @DateValue variable, and it now holds the date &#8216;2023-01-15&#8217; in the desired format.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-handling-conversion-errors-with-the-try-functions\">Handling Conversion Errors with the TRY_* functions<\/h2>\n\n\n\n<p>Handling conversion errors is important to avoid unexpected issues. SQL Server provides functions like TRY_CAST(), TRY_CONVERT(), and TRY_PARSE() for this purpose. These functions return NULL if the conversion fails, allowing you to gracefully manage erroneous data.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"mssql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">DECLARE @DateString VARCHAR(10) = '15\/01\/2023';\nDECLARE @DateValue DATE;\n\n-- Using the 'en-US' culture for dd\/MM\/yyyy format\nSET @DateValue = PARSE(@DateString AS DATE USING 'en-US');\n<\/pre>\n\n\n\n<p>In this example, the TRY_CAST() built-in SQL function is used to convert an invalid string to a date, resulting in a NULL value for @DateValue.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-sql-server-offers-multiple-conversion-options\">SQL Server offers multiple conversion options<\/h2>\n\n\n\n<p>To convert a string to a date format in SQL Server is a common but often mandatory task when dealing with date-related data. Indeed, you often need to perform implicit or explicit conversions for example, or handle conversion errors gracefully. <\/p>\n\n\n\n<p>To do so, SQL Server offers a range of functions to ensure accurate and reliable date conversion. By mastering these techniques, you&#8217;ll be better equipped to work with date values in your SQL Server databases. These functions can be used for columns as well as for variables of course.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Different solutions to convert a date stored in a text to a date format using T-SQL functions. When working with data in SQL Server, you may encounter situations where you must convert dates that are stored as strings to <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/\" title=\"How to convert a string to a date format in SQL Server ?\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":6263,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-29319","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-t-sql"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.7 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to convert a string to a date format in SQL Server ? T-SQL<\/title>\n<meta name=\"description\" content=\"Convert a string to a date format in SQL Server using the CAST, FORMAT, CONVERT and the PARSE conversion functions in T-SQL scripts.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to convert a string to a date format in SQL Server ?\" \/>\n<meta property=\"og:description\" content=\"Convert a string to a date format in SQL Server using the CAST, FORMAT, CONVERT and the PARSE conversion functions in T-SQL scripts.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL and IT Tutorials\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-20T04:16:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-23T10:43:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/hour-glass-sands-of-time-4F71097A077_1920x1080.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Expert-Only\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@expert_only\" \/>\n<meta name=\"twitter:site\" content=\"@expert_only\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Expert-Only\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How to convert a string to a date format in SQL Server ?\",\"datePublished\":\"2023-11-20T04:16:00+00:00\",\"dateModified\":\"2023-11-23T10:43:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/\"},\"wordCount\":697,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/hour-glass-sands-of-time-4F71097A077_1920x1080.jpeg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/\",\"name\":\"How to convert a string to a date format in SQL Server ? T-SQL\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/hour-glass-sands-of-time-4F71097A077_1920x1080.jpeg\",\"datePublished\":\"2023-11-20T04:16:00+00:00\",\"dateModified\":\"2023-11-23T10:43:28+00:00\",\"description\":\"Convert a string to a date format in SQL Server using the CAST, FORMAT, CONVERT and the PARSE conversion functions in T-SQL scripts.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/hour-glass-sands-of-time-4F71097A077_1920x1080.jpeg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/hour-glass-sands-of-time-4F71097A077_1920x1080.jpeg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to convert a string to a date format in SQL Server ?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/expert-only.com\/en\/#website\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"name\":\"SQL and IT Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/expert-only.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/expert-only.com\/en\/#organization\",\"name\":\"Expert-Only\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"width\":381,\"height\":174,\"caption\":\"Expert-Only\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\",\"https:\/\/x.com\/expert_only\",\"https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\",\"name\":\"Expert-Only\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"caption\":\"Expert-Only\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to convert a string to a date format in SQL Server ? T-SQL","description":"Convert a string to a date format in SQL Server using the CAST, FORMAT, CONVERT and the PARSE conversion functions in T-SQL scripts.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"How to convert a string to a date format in SQL Server ?","og_description":"Convert a string to a date format in SQL Server using the CAST, FORMAT, CONVERT and the PARSE conversion functions in T-SQL scripts.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2023-11-20T04:16:00+00:00","article_modified_time":"2023-11-23T10:43:28+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/hour-glass-sands-of-time-4F71097A077_1920x1080.jpeg","type":"image\/jpeg"}],"author":"Expert-Only","twitter_card":"summary_large_image","twitter_creator":"@expert_only","twitter_site":"@expert_only","twitter_misc":{"Written by":"Expert-Only","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How to convert a string to a date format in SQL Server ?","datePublished":"2023-11-20T04:16:00+00:00","dateModified":"2023-11-23T10:43:28+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/"},"wordCount":697,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/hour-glass-sands-of-time-4F71097A077_1920x1080.jpeg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/","url":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/","name":"How to convert a string to a date format in SQL Server ? T-SQL","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/hour-glass-sands-of-time-4F71097A077_1920x1080.jpeg","datePublished":"2023-11-20T04:16:00+00:00","dateModified":"2023-11-23T10:43:28+00:00","description":"Convert a string to a date format in SQL Server using the CAST, FORMAT, CONVERT and the PARSE conversion functions in T-SQL scripts.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/hour-glass-sands-of-time-4F71097A077_1920x1080.jpeg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/08\/hour-glass-sands-of-time-4F71097A077_1920x1080.jpeg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/convert-string-to-date-in-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to convert a string to a date format in SQL Server ?"}]},{"@type":"WebSite","@id":"https:\/\/expert-only.com\/en\/#website","url":"https:\/\/expert-only.com\/en\/","name":"SQL and IT Tutorials","description":"","publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/expert-only.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/expert-only.com\/en\/#organization","name":"Expert-Only","url":"https:\/\/expert-only.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","width":381,"height":174,"caption":"Expert-Only"},"image":{"@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ExpertOnlyCom\/","https:\/\/x.com\/expert_only","https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA"]},{"@type":"Person","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef","name":"Expert-Only","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","caption":"Expert-Only"}}]}},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/29319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=29319"}],"version-history":[{"count":15,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/29319\/revisions"}],"predecessor-version":[{"id":29346,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/29319\/revisions\/29346"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/6263"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=29319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=29319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=29319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}