Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get default value for date

Tags:

sql

sql-server

According to the doc the default value of a date in SQL Server is

1900-01-01 00:00:00

Can I call the default value in any way? For instance like this

select isnull(date_column, default(date_column))
from my_table
like image 418
juergen d Avatar asked Jul 05 '26 09:07

juergen d


1 Answers

Perhaps:

SELECT DefaultDate = CAST(0 AS DATETIME) 

sql-Fiddle

If you need a DATE you can cast it also:

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

sql-fiddle

like image 125
Tim Schmelter Avatar answered Jul 08 '26 05:07

Tim Schmelter