Created
July 29, 2013 14:17
-
-
Save AlexArchive/6104604 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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