Skip to content

Instantly share code, notes, and snippets.

@AlexArchive
Created July 29, 2013 14:17
Show Gist options
  • Save AlexArchive/6104604 to your computer and use it in GitHub Desktop.
Save AlexArchive/6104604 to your computer and use it in GitHub Desktop.
-- Note that the proceeding queries interpert the date
-- differently based on the language (culture):
SET LANGUAGE BRITISH;
PRINT CAST('02/12/2007' AS DATETIME);
SET LANGUAGE us_english;
PRINT CAST('02/12/2007' AS DATETIME);
-- Using a language-neutral Date format results in
-- both dates being interpereted as the same:
SET LANGUAGE BRITISH;
PRINT CAST('20070212' AS DATETIME);
SET LANGUAGE us_english;
PRINT CAST('20070212' AS DATETIME);
-- Should you insist on using a language-dependant
-- format you could use CONVERT:
PRINT CONVERT(DATETIME, '02/12/2007', 101);
PRINT CONVERT(DATETIME, '02/12/2007', 103);
-- Another optionis to use the PARSE function:
PRINT PARSE('02/12/2007' AS DATETIME USING 'en-US');
PRINT PARSE('02/12/2007' AS DATETIME USING 'en-GB');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment