|
INTERVIEW QUESTIONS
DATABASE
MS SQL SERVER
DETAILS
Question: What Are Out-of-Range Errors with Date and Time Literals?
Answer: When you enter data and time literals, you may get out-of-range errors due to two common mistakes:
* The date value is a valid calendar date, but it is not in the range covered by DATETIME data type: from January 1, 1753, to December 31, 9999. * The date value is not a valid calendar date, for example: 30-Feb-2007. * The time value does not represent a valid time, for example: 24:55:07.233.
The tutorial exercise below shows you some data and time out-of-range errors:
-- Invalid date DECLARE @x DATETIME; SET @x = '30-Feb-2007 22:55:07.233'; GO Msg 242, Level 16, State 3, Line 2 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
-- Date below the DATETIME limits DECLARE @x DATETIME; SET @x = '19-May-1752 22:55:07.233'; GO Msg 242, Level 16, State 3, Line 2 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
-- Invalid time DECLARE @x DATETIME; SET @x = '19-May-2007 24:55:07.233'; GO Msg 242, Level 16, State 3, Line 2 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
|
|
|
Category |
MS SQL Server Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9375 users |
Added on |
9/23/2014 |
Views |
67329 |
Rate it! |
|
|
Question:
What Are Out-of-Range Errors with Date and Time Literals?
Answer:
When you enter data and time literals, you may get out-of-range errors due to two common mistakes:
* The date value is a valid calendar date, but it is not in the range covered by DATETIME data type: from January 1, 1753, to December 31, 9999. * The date value is not a valid calendar date, for example: 30-Feb-2007. * The time value does not represent a valid time, for example: 24:55:07.233.
The tutorial exercise below shows you some data and time out-of-range errors:
-- Invalid date DECLARE @x DATETIME; SET @x = '30-Feb-2007 22:55:07.233'; GO Msg 242, Level 16, State 3, Line 2 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
-- Date below the DATETIME limits DECLARE @x DATETIME; SET @x = '19-May-1752 22:55:07.233'; GO Msg 242, Level 16, State 3, Line 2 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
-- Invalid time DECLARE @x DATETIME; SET @x = '19-May-2007 24:55:07.233'; GO Msg 242, Level 16, State 3, Line 2 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. 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 Time-Only Values Are Provided as Date and Time Literals?
|
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
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All MS SQL Server Interview Questions & Answers - Exam Mode /
Learning Mode
|