Try this

Cast('7/7/2011' as datetime)

and

Convert(DATETIME, '7/7/2011', 101)

See CAST and CONVERT (Transact-SQL) for more details.

Answer from gauravg on Stack Overflow
🌐
W3Schools
w3schools.com › sql › func_sqlserver_convert.asp
SQL Server CONVERT() Function
String Functions: ASCII CHAR_LENGTH CHARACTER_LENGTH CONCAT CONCAT_WS FIELD FIND_IN_SET FORMAT INSERT INSTR LCASE LEFT LENGTH LOCATE LOWER LPAD LTRIM MID POSITION REPEAT REPLACE REVERSE RIGHT RPAD RTRIM SPACE STRCMP SUBSTR SUBSTRING SUBSTRING_INDEX TRIM UCASE UPPER Numeric Functions: ABS ACOS ASIN ATAN ATAN2 AVG CEIL CEILING COS COT COUNT DEGREES DIV EXP FLOOR GREATEST LEAST LN LOG LOG10 LOG2 MAX MIN MOD PI POW POWER RADIANS RAND ROUND SIGN SIN SQRT SUM TAN TRUNCATE Date Functions: ADDDATE ADDTIME CURDATE CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURTIME DATE DATEDIFF DATE_ADD DATE_FORMAT DA
🌐
DotFactory
dofactory.com › sql › convert-string-to-datetime
SQL Convert String to DATETIME
SELECT TRY_CONVERT(datetime, '2022-11-01 05:29 PM', 0) AS 'mon dd yyyy hh:miAM/PM)', TRY_CONVERT(datetime, '2022-11-01 05:29 PM', 101) AS 'mm/dd/yyyy', TRY_CONVERT(datetime, '2022-11-01 05:29 PM', 3) AS 'dd/mm/yy', TRY_CONVERT(datetime, '2022-11-01 05:29 PM', 104) AS 'dd.mm.yyyy', ...
🌐
SQL Server Tutorial
sqlservertutorial.net › home › sql server system functions › convert string to datetime
Convert String to Datetime in SQL Server
April 11, 2020 - SELECT TRY_CONVERT(DATETIME, '2019-18-15', 102) result; Code language: SQL (Structured Query Language) (sql) ... result ----------------------- NULL (1 row affected) Code language: SQL (Structured Query Language) (sql) Both CONVERT() and TRY_CONVERT() function can recognize ANSI/ISO and US ...
🌐
MSSQLTips
mssqltips.com › home › sql date format examples using convert function
SQL Date Format Examples using SQL CONVERT Function
September 26, 2025 - --SELECT a datetime column as a string formatted dd/mm/yyyy (4 digit year) SELECT TOP 3 CONVERT(CHAR(10), ExpectedDeliveryDate, 103) ExpectedDeliveryDateFormattedAsText FROM Purchasing.PurchaseOrders WHERE OrderDate < @Datetime; --SELECT a datetime column as a string formatted dd/mm/yy (2 digit year) SELECT TOP 3 CONVERT(CHAR(8), ExpectedDeliveryDate, 3) ExpectedDeliveryDateFormattedAsText FROM Purchasing.PurchaseOrders WHERE OrderDate < @Datetime; Once the query runs, review SQL CONVERT output as shown below.
Top answer
1 of 16
368

Try this

Cast('7/7/2011' as datetime)

and

Convert(DATETIME, '7/7/2011', 101)

See CAST and CONVERT (Transact-SQL) for more details.

2 of 16
62

Run this through your query processor. It formats dates and/or times like so and one of these should give you what you're looking for. It wont be hard to adapt:

Declare @d datetime
select @d = getdate()

select @d as OriginalDate,
convert(varchar,@d,100) as ConvertedDate,
100 as FormatValue,
'mon dd yyyy hh:miAM (or PM)' as OutputFormat
union all
select @d,convert(varchar,@d,101),101,'mm/dd/yy'
union all
select @d,convert(varchar,@d,102),102,'yy.mm.dd'
union all
select @d,convert(varchar,@d,103),103,'dd/mm/yy'
union all
select @d,convert(varchar,@d,104),104,'dd.mm.yy'
union all
select @d,convert(varchar,@d,105),105,'dd-mm-yy'
union all
select @d,convert(varchar,@d,106),106,'dd mon yy'
union all
select @d,convert(varchar,@d,107),107,'Mon dd, yy'
union all
select @d,convert(varchar,@d,108),108,'hh:mm:ss'
union all
select @d,convert(varchar,@d,109),109,'mon dd yyyy hh:mi:ss:mmmAM (or PM)'
union all
select @d,convert(varchar,@d,110),110,'mm-dd-yy'
union all
select @d,convert(varchar,@d,111),111,'yy/mm/dd'
union all
select @d,convert(varchar,@d,12),12,'yymmdd'
union all
select @d,convert(varchar,@d,112),112,'yyyymmdd'
union all
select @d,convert(varchar,@d,113),113,'dd mon yyyy hh:mm:ss:mmm(24h)'
union all
select @d,convert(varchar,@d,114),114,'hh:mi:ss:mmm(24h)'
union all
select @d,convert(varchar,@d,120),120,'yyyy-mm-dd hh:mi:ss(24h)'
union all
select @d,convert(varchar,@d,121),121,'yyyy-mm-dd hh:mi:ss.mmm(24h)'
union all
select @d,convert(varchar,@d,126),126,'yyyy-mm-dd Thh:mm:ss:mmm(no spaces)'
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › functions › cast-and-convert-transact-sql
CAST and CONVERT (Transact-SQL) - SQL Server | Microsoft Learn
For example, this conversion returns $10.3497: ... SQL Server returns an error message when converting nonnumeric char, nchar, nvarchar, or varchar data to decimal, float, int, numeric.
🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-query-to-convert-datetime-to-string
SQL Query to Convert Datetime to String - GeeksforGeeks
July 23, 2025 - /*Declaring DATETIME as dt*/ DECLARE @dt DATETIME = (SELECT order_date FROM orders WHERE prod_id = 101); /*SELECT statement is used to print the s1 message*/ SELECT CONVERT(VARCHAR(20),@dt,0) s1;
🌐
Alibaba Cloud
alibabacloud.com › help › en › maxcompute › use-cases › convert-data-types-among-string-timestamp-and-datetime
Convert data types among STRING, TIMESTAMP, and DATETIME - MaxCompute - Alibaba Cloud Documentation Center
To construct data of the TIMESTAMP type, you must use the CAST function once. Sample statement: -- The return value is 2009-07-01 16:09:00. select to_char(cast('2009-07-01 16:09:00' as timestamp),'yyyy-mm-dd hh:mi:ss'); ... Convert a date value of the TIMESTAMP type to the DATETIME type.
Find elsewhere
🌐
SQLines
sqlines.com › oracle-to-sql-server › to_date
TO_DATE - Convert String to Datetime - Oracle to SQL Server Migration - SQLines Tools
In Oracle, TO_DATE function converts ... an appropriate datetime style. Oracle: -- Specify a datetime string and its exact format SELECT TO_DATE('2012-06-05', 'YYYY-MM-DD') FROM dual;...
🌐
Database Guide
database.guide › how-to-convert-a-string-to-a-date-time-in-sql-server-using-cast
How to Convert a String to a Date/Time in SQL Server using CAST()
SELECT CAST('2pm 20 Dec 2018' AS datetime) AS Result; ... +-------------------------+ | Result | |-------------------------| | 2018-12-20 14:00:00.000 | +-------------------------+ ... +-----------------------------+ | Result | |-----------------------------| | 2018-12-20 00:00:00.0000000 | ...
🌐
SQL Shack
sqlshack.com › sql-server-functions-for-converting-string-to-date
SQL Server functions for converting a String to a Date
May 21, 2021 - In SQL Server, converting string to date implicitly depends on the string date format and the default language settings (regional settings); If the date stored within a string is in ISO formats: yyyyMMdd or yyyy-MM-ddTHH:mm:ss(.mmm), it can be converted regardless of the regional settings, else the date must have a supported format or it will throw an exception, as an example while working under the regional settings “EN-US”, if we try to convert a string with dd/MM/yyyy format it will fail since it tries to convert it as MM/dd/yyyy format which is supported. ... Msg 242, Level 16, State 3, Line 1 The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. ... You can check out this official documentation here to learn more about how to change SQL Server language settings.
🌐
DotFactory
dofactory.com › sql › convert-datetime-to-string
SQL Convert DATETIME to String
Converting a datetime to a string value is a common requirement. Use CONVERT or TRY_CONVERT to perform this operation. This example converts the current datetime to a string.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 685628 › convert-string-to-date
convert string to date - Microsoft Q&A
Based on your question, I believe insta_map_date is a varchar field. and based on the source data sample you provided, the date format matches with ISO8601. So you can use 126 or 127 as the style while converting to datetime. Try the following. ... For more information about SQL Server Date Formats, refer : https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver15
🌐
SQL Tutorial
sqltutorial.org › home › sql date functions › sql convert string to date functions
SQL Convert String to Date Functions: CAST() and TO_DATE()
April 4, 2020 - This tutorial shows you how to use the CAST() and TO_DATE() to convert a string to a date in SQL.
🌐
LearnSQL.com
learnsql.com › cookbook › how-to-extract-or-convert-time-data-from-a-string-in-sql-server
How to Convert Time Data from Strings in SQL Server | LearnSQL.com
SELECT CAST('2 February 2020 11:23:11.1134505' AS TIME) AS time_value; ... The string containing the date and time to convert must be in the format of the T-SQL date and time data type.
🌐
StarRocks
docs.starrocks.io › reference › sql functions › date and time › str_to_date
str_to_date - Converts a string into a DATETIME value
MySQL > select str_to_date('2014-12-21 12:34:56', '%Y-%m-%d'); +--------------------------------------------------------------+ | str_to_date('2014-12-21 12:34:56', '%Y-%m-%d') | +--------------------------------------------------------------+ ...
🌐
MariaDB
mariadb.com › docs › server › reference › sql-functions › date-time-functions › str_to_date
STR_TO_DATE | Server | MariaDB Documentation
SELECT STR_TO_DATE('Wednesday, June 2, 2014', '%W, %M %e, %Y'); +---------------------------------------------------------+ | STR_TO_DATE('Wednesday, June 2, 2014', '%W, %M %e, %Y') | +---------------------------------------------------------+ ...