DateTime values should be inserted as if they were strings surrounded by single quotes:
'20100301'
SQL Server allows you to use many accepted date formats, and in most cases, development libraries provide a number of classes or functions to correctly enter date and time values. However, if you do this manually, it is important to distinguish between the date format using DateFormat and use a generic format:
Set DateFormat MDY
By setting the date format, SQL Server now assumes that my format is YYYY-MM-DD instead of YYYY-DD-MM .
SET DATEFORMAT
SQL Server also recognizes a common format that is always interpreted the same way: YYYYMMDD for example. 20110312 .
If you are asking how to insert the current date and time using T-SQL, I would recommend using the keyword CURRENT_TIMESTAMP . For example:
Insert Table( DateTimeCol ) Values( CURRENT_TIMESTAMP )
Thomas Mar 13 2018-11-11T00: 00Z
source share