By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
DECLARE @Iso varchar(20) = '2023-09-13T16:18:32',
@Odbc varchar(16) ='2023-09-13 16:18:32';
SELECT TRY_CAST(@Iso As DateTime) As Iso,
TRY_CAST(@Odbc As DateTime) As Compact;
SET DateFormat YMD;
SELECT TRY_CAST(@Iso As DateTime) As Iso,
TRY_CAST(@Odbc As DateTime) As Compact;
SET DateFormat YDM;
SELECT TRY_CAST(@Iso As DateTime) As Iso,
TRY_CAST(@Odbc As DateTime) As Compact;
Iso | Compact |
---|---|
2023-09-13 16:18:32.000 | 2023-09-13 16:18:00.000 |
Iso | Compact |
---|---|
2023-09-13 16:18:32.000 | 2023-09-13 16:18:00.000 |
Iso | Compact |
---|---|
2023-09-13 16:18:32.000 | null |