finding max possible date in ms sql server 2005+

前端 未结 7 1200
名媛妹妹
名媛妹妹 2021-01-01 08:22

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

7条回答
  •  耶瑟儿~
    2021-01-01 09:05

    In my SQL Server 2008 r2, I get these odd results (not that I'm ever going to miss those 3 milleseconds)

    SELECT cast('12/31/9999 23:59:59.997' as datetime) --RETURNS '9999-12-31 23:59:59.997'
    SELECT cast('12/31/9999 23:59:59.998' as datetime) --RETURNS '9999-12-31 23:59:59.997'
    SELECT cast('12/31/9999 23:59:59.999' as datetime) --RETURNS The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
    

提交回复
热议问题