MS SQL Server Concepts and Programming Question:

What Happens If Time-Only Values Are Provided as Date and Time Literals?

Tweet Share WhatsApp

Answer:

If only time value is provided in a data and time literal, the SQL Server will pad the date value with a zero, representing the base date, January 1, 1900. The tutorial exercise below gives you some good examples:

-- 'hh:mi:ss.mmm' format
DECLARE @x DATETIME;
SET @x = '22:55:07.233';
SELECT @x;
GO
1900-01-01 22:55:07.233

-- 'hh:mi:ss.mmmAM/PM' format
DECLARE @x DATETIME;
SET @x = '10:55:07.233PM';
SELECT @x;
GO
1900-01-01 22:55:07.233

-- 'hh:miAM/PM' format
DECLARE @x DATETIME;
SET @x = '10:55PM';
SELECT @x;
GO
1900-01-01 22:55:00.000


Download MS SQL Server PDF Read All 394 MS SQL Server Questions
Previous QuestionNext Question
What Happens If Date-Only Values Are Provided as Date and Time Literals?What Are Out-of-Range Errors with Date and Time Literals?