Collections:
Entering Date and Time Values in SQL Server
How To Enter Date and Time values in SQL Server Transact-SQL?
✍: FYIcenter.com
Transact-SQL does not support date and time literals. If you want to enter date and time values, you have to use character string literals and rely implicit casting rules to convert them into date and time values.
When casting character string literals into DATETIME values, you can use one of these recognizable data and time formats shown below:
-- Default format for query output DECLARE @x DATETIME; SET @x = '2017-05-19 22:55:07.233'; SELECT @x; ---------------------------- 2017-05-19 22:55:07.233 -- Default for string print output DECLARE @x DATETIME; SET @x = 'May 19 2017 10:55PM'; SELECT @x; ---------------------------- 2017-05-19 22:55:00.000 -- Europe default format DECLARE @x DATETIME; SET @x = '19-May-2017 22:55:07.233'; SELECT @x; ---------------------------- 2017-05-19 22:55:07.233 -- ISO8601 standard format DECLARE @x DATETIME; SET @x = '2017-05-19T22:55:07.233'; SELECT @x; ---------------------------- 2017-05-19 22:55:07.233
⇒ Casting Numeric Values to DATETIME in SQL Server Transact-SQL
⇐ Date and Time Data Types in SQL Server Transact-SQL
2017-04-15, 1401🔥, 0💬
Popular Posts:
How To Get a List of All Tables with "sys.tables" View in SQL Server? If you want to see the table y...
How To Change the Name of a Database User in SQL Server? If you want to change the name of an existi...
How To Use SQL*Plus Built-in Timers in Oracle? If you don't have a stopwatch/timer and want to measu...
What Is the Difference Between GETDATE() and GETUTCDATE() in SQL Server Transact-SQL? The difference...
How To Drop an Index in Oracle? If you don't need an existing index any more, you should delete it w...