How to add date as a column in SQL server? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to add date as a column in SQL server?

I want to add date column in my SQL table. It is giving me the error: cannot find the data type DATE. I tried writing: Create table employee( EmpID varchar(10), RetireDate DATE, Branch Varchar(20)); I also tried writing the date data type as: RetireDate Date RetireDate date RetireDate DATE(YYYY/MM/DD) RetireDate date(yyyy/mm/dd) But everytime it is giving the same error.

2nd Aug 2019, 5:58 PM
Chetali Shah
Chetali Shah - avatar
3 Answers
2nd Aug 2019, 6:07 PM
silentlearner
silentlearner - avatar
+ 2
Previous SQL Server versions only support the datetime and smalldatetime data type.
2nd Aug 2019, 6:14 PM
Michael
Michael - avatar
+ 1
smalldatetime and datetime both worked. Thank you
2nd Aug 2019, 6:20 PM
Chetali Shah
Chetali Shah - avatar