|
INTERVIEW QUESTIONS
DATABASE
MS SQL SERVER
DETAILS
Question: What Happens If Time-Only Values Are Provided as Date and Time Literals?
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
|
|
|
Category |
MS SQL Server Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 8726 users |
Added on |
9/23/2014 |
Views |
71285 |
Rate it! |
|
|
Question:
What Happens If Time-Only Values Are Provided as Date and Time Literals?
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 Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What Happens If Date-Only Values Are Provided as Date and Time Literals?
|
View Answer
|
|
Why I Can Not Enter 0.001 Second in Date and Time Literals in MS SQL Server?
|
View Answer
|
|
How To Enter Date and Time Literals in MS SQL Server?
|
View Answer
|
|
How To Enter Binary String Literals in MS SQL Server?
|
View Answer
|
|
How To Enter Unicode Character String Literals in MS SQL Server?
|
View Answer
|
|
How Fixed Length Strings Are Truncated and Padded?
|
View Answer
|
|
How To Find Out What Is the Default Collation in a Database?
|
View Answer
|
|
What Happens If Strings Are Casted into Wrong Code Pages in MS SQL Server?
|
View Answer
|
|
How To Specify the Collation for a Character Data Type in MS SQL Server?
|
View Answer
|
|
What Is a Collation in MS SQL Server?
|
View Answer
|
|
How To Write Character String Constants or Literals in MS SQL Server?
|
View Answer
|
|
What Is a Constant or Literal in MS SQL Server?
|
View Answer
|
|
What Are the Differences between DECIMAL and FLOAT in MS SQL Server?
|
View Answer
|
|
What Are the Differences between CHAR and VARCHAR in MS SQL Server?
|
View Answer
|
|
What Are the Differences between CHAR and NCHAR in MS SQL Server?
|
View Answer
|
|
What Are Binary String Data Types in MS SQL Server?
|
View Answer
|
|
What Are Unicode Character String Data Types in MS SQL Server?
|
View Answer
|
|
What Are Character String Data Types in MS SQL Server?
|
View Answer
|
|
What Are Date and Time Data Types in MS SQL Server?
|
View Answer
|
|
What Are Approximate Numeric Data Types in MS SQL Server?
|
View Answer
|