SELECT
convert
(datetime,
'Oct 23 2012 11:01AM'
, 100)
SELECT
convert
(datetime,
'Oct 23 2012 11:01AM'
)
-- Without century (yy) string date conversion - convert string to datetime
SELECT
convert
(datetime,
'Oct 23 12 11:01AM'
, 0)
SELECT
convert
(datetime,
'Oct 23 12 11:01AM'
)
-- Convert string to datetime sql - convert string to date sql - sql dates format
-- T-SQL convert string to datetime - SQL Server convert string to date
SELECT
convert
(datetime,
'10/23/2016'
, 101)
SELECT
convert
(datetime,
'2016.10.23'
, 102)
SELECT
convert
(datetime,
'23/10/2016'
, 103)
SELECT
convert
(datetime,
'23.10.2016'
, 104)
SELECT
convert
(datetime,
'23-10-2016'
, 105)
-- mon types are nondeterministic conversions, dependent on language setting
SELECT
convert
(datetime,
'23 OCT 2016'
, 106)
SELECT
convert
(datetime,
'Oct 23, 2016'
, 107)
-- 2016-10-23 00:00:00.000
SELECT
convert
(datetime,
'20:10:44'
, 108)
-- 1900-01-01 20:10:44.000
-- mon dd yyyy hh:mm:ss:mmmAM (or PM) - sql time format
SELECT
convert
(datetime,
'Oct 23 2016 11:02:44:013AM'
, 109)
-- 2016-10-23 11:02:44.013
SELECT
convert
(datetime,
'10-23-2016'
, 110)
SELECT
convert
(datetime,
'2016/10/23'
, 111)
SELECT
convert
(datetime,
'20161023'
, 112)
-- 2016-10-23 00:00:00.000
SELECT
convert
(datetime,
'23 Oct 2016 11:02:07:577'
, 113)
-- 2016-10-23 11:02:07.577
SELECT
convert
(datetime,
'20:10:25:300'
, 114)
-- 1900-01-01 20:10:25.300
SELECT
convert
(datetime,
'2016-10-23 20:44:11'
, 120)
-- 2016-10-23 20:44:11.000
SELECT
convert
(datetime,
'2016-10-23 20:44:11.500'
, 121)
-- 2016-10-23 20:44:11.500
SELECT
convert
(datetime,
'2008-10-23T18:52:47.513'
, 126)
-- 2008-10-23 18:52:47.513
-- Convert DDMMYYYY format to datetime
SELECT
convert
(datetime, STUFF(STUFF(
'31012016'
,3,0,
'-'
),6,0,
'-'
), 105)
-- 2016-01-31 00:00:00.000
-- SQL string to datetime conversion without century - some exceptions
SELECT
convert
(datetime,
'10/23/16'
, 1)
SELECT
convert
(datetime,
'16.10.23'
, 2)
SELECT
convert
(datetime,
'23/10/16'
, 3)
SELECT
convert
(datetime,
'23.10.16'
, 4)
SELECT
convert
(datetime,
'23-10-16'
, 5)
SELECT
convert
(datetime,
'23 OCT 16'
, 6)
SELECT
convert
(datetime,
'Oct 23, 16'
, 7)
SELECT
convert
(datetime,
'20:10:44'
, 8)
SELECT
convert
(datetime,
'Oct 23 16 11:02:44:013AM'
, 9)
SELECT
convert
(datetime,
'10-23-16'
, 10)
SELECT
convert
(datetime,
'16/10/23'
, 11)
SELECT
convert
(datetime,
'161023'
, 12)
SELECT
convert
(datetime,
'23 Oct 16 11:02:07:577'
, 13)
SELECT
convert
(datetime,
'20:10:25:300'
, 14)
SELECT
convert
(datetime,
'2016-10-23 20:44:11'
,20)
SELECT
convert
(datetime,
'2016-10-23 20:44:11.500'
, 21)