Is there a function like GETDATE() in Sql Server 2005 that let\'s you get the max possible date?
I do not want to find the highest date in a table. I wa
CAST() seems to be dependent on the SQL Server language/culture.
On my German SQL Servers 2008 R2 and 2012 (@@language = 'Deutsch'), the following cast throws an error:
CAST('12/31/9999 23:59:59.997' AS DATETIME)
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Whereas this one works just fine:
CAST('31.12.9999 23:59:59.997' AS DATETIME)
SOLUTION
I think the safest approach is to specify the format with CONVERT():
/* ISO 8601 */
CONVERT(DATETIME, '9999-12-31T23:59:59.997', 126)