clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3799014 fiddles created (41865 in the last week).

-- works in default us_english SELECT CAST('2022-05-27' AS datetime);
(No column name)
2022-05-27 00:00:00.000
 hidden batch(es)


-- fails in British (and more than half of SQL Server's supported langs)! SET LANGUAGE British; SELECT CAST('2022-05-27' AS datetime);
Msg 242 Level 16 State 3 Line 3 The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
 hidden batch(es)


-- need CONVERT for this trick, not CAST: SET LANGUAGE British; SELECT CONVERT(datetime, '2022-05-27', 120);
(No column name)
2022-05-27 00:00:00.000
Changed language setting to British.
 hidden batch(es)