Blog Pages

two digit year cutoff

-- show settings:
EXEC sp_configure 'two digit year cutoff'
GO

-- two digit year cutoff configuration:
EXEC sys.sp_configure N'two digit year cutoff', N'2030'
GO
RECONFIGURE WITH OVERRIDE
GO
-- or In Object Explorer, in the server Properties

By default, SQL Server interprets two-digit years based on a cutoff year of 2049:
SELECT CAST('02/02/02' AS DATETIME), 
CAST('02/02/49' AS DATETIME),
CAST('02/02/50' AS DATETIME)
-- output:  2002-02-02,2049-02-02,1950-02-02

Specifying four-digit years is Always recommended.

No comments:

Post a Comment