Collections:
Date-Only DATETIME Values in SQL Server Transact-SQL
What Happens If Date-Only Values Are Provided for DATETIME in SQL Server Transact-SQL?
✍: FYIcenter.com
If only date value is provided in a DATETIME variable, the SQL Server will pad the time value with a zero, or '00:00:00.000', representing the midnight time of the day. The tutorial exercise below gives you some good examples:
-- 'mm/dd/yyyy' format DECLARE @x DATETIME; SET @x = '05/19/2017'; SELECT @x; ----------------------- 2017-05-19 00:00:00.000 -- 'mm.dd.yy' format DECLARE @x DATETIME; SET @x = '05.19.07'; SELECT @x; ----------------------- 2017-05-19 00:00:00.000 -- 'yyyy-mm-dd' format DECLARE @x DATETIME; SET @x = '2017-05-19'; SELECT @x; ----------------------- 2017-05-19 00:00:00.000 -- 'mon dd, yyyy' format DECLARE @x DATETIME; SET @x = 'May 19, 2017'; SELECT @x; ----------------------- 2017-05-19 00:00:00.000 -- 'dd-mon-yyyy' format DECLARE @x DATETIME; SET @x = '19-May-2017'; SELECT @x; ----------------------- 2017-05-19 00:00:00.000
⇒ Time-Only DATETIME Values in SQL Server Transact-SQL
⇐ Entering 0.001 Second in DATETIME in SQL Server Transact-SQL
2017-04-08, 1694🔥, 0💬
Popular Posts:
What Is Oracle in Oracle? Oracle is a company. Oracle is also a database server, which manages data ...
How To Generate Random Numbers with the RAND() Function in SQL Server Transact-SQL? Random numbers a...
What Are Out-of-Range Errors with DATETIME values in SQL Server Transact-SQL? When you enter DATETIM...
What Happens If the UPDATE Subquery Returns Multiple Rows in MySQL? If a subquery is used in a UPDAT...
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...