Getting Maximum Datetime Value Programmatically

How can I get the maximum value of a DATETIME data type in SQL Server 2005 programmatically? I do not want to use NULL as the value of the column, and I do not want to use CONVERT(DATETIME, '12/31/9999 23:59:59.997') .

Thank you very much.

+4
source share
2 answers

You can check the value as follows:

 PRINT 'The maximum date value ' + CASE ISDATE('9999-12-31 23:59:59.998') + ISDATE('9999-12-31 23:59:59.999') WHEN 0 THEN 'IS LESS THAN' WHEN 1 THEN 'EQUALS' WHEN 2 THEN 'IS GREATER THAN' END + ' 9999-12-31 23:59:59.998' 

Output:

 The maximum date value EQUALS 9999-12-31 23:59:59.998 
+2
source

Must be in the documents ... Until December 31, 9999.

+1
source

All Articles