获取日期的默认值

时间:2013-09-10 12:58:18

标签: sql sql-server

根据the doc,SQL Server中日期的默认值

1900-01-01 00:00:00

我能以任何方式调用默认值吗?比如像这样

select isnull(date_column, default(date_column))
from my_table

2 个答案:

答案 0 :(得分:6)

也许:

SELECT DefaultDate = CAST(0 AS DATETIME) 

sql-Fiddle

如果你需要DATE,你也可以投射它:

SELECT DefaultDate = CAST(CAST(0 AS DATETIME) AS DATE)

sql-fiddle

答案 1 :(得分:3)

select MinimumDate = cast(dateadd(d, 0, 0) as date)