finding max possible date in ms sql server 2005+

前端 未结 7 1228
名媛妹妹
名媛妹妹 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:08

    The documentation says the range is January 1, 1753, through December 31, 9999.

    I don't think there is a built in function, but you could create one that returns the maximum datetime value.

    CREATE FUNCTION fn_max_date
    RETURNS datetime
    AS
    return cast('12/31/9999 23:59:59.9999' as datetime)
    

提交回复
热议问题