By using this site, you acknowledge that you have read and understand our Cookie policy, Privacy policy and Terms .
close

Code snippets for various programming languages/frameworks.

rss_feed Subscribe RSS

This code snippet shows how to convert string to date.

In SQL Server, CAST and CONVERT functions can be used to convert string/varchar to date.

For CONVERT function, there are many style argument you can use. 

For the complete list of styles supported, please refer to the following official page:

CAST and CONVERT (Transact-SQL)

Code snippet

SELECT CAST('2017-10-15' AS DATE);
SELECT CAST('20171015' AS DATE);
SELECT CONVERT(DATE,'2017-10-15',121);
SELECT CONVERT(DATE,'15-10-2017',105);
SELECT CONVERT(DATE,'15 OCT 2017',113);
SELECT CONVERT(DATE,'20171015',112);
info Last modified by Raymond at 8 months ago
info About author

info License/Terms

Please log in or register to comment. account_circle Log in person_add Register
comment Comments (0)
No comments yet.