Raymond
Convert string to date in T-SQL / SQL Server
insights Stats
warning Please login first to view stats information.
toc Table of contents
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 5 years ago
copyright
This page is subject to Site terms.
comment Comments
No comments yet.