Multiple Choice Questions - SQL Server Date / Time
1. From the below options (queries and their results) choose the correct values returned by SYSDATETIME() and GETDATE(). Which of the below two options are correct:
A) SELECT SYSDATETIME()
2014-07-28 17:48:41.0528876
B) SELECT GETDATE()
2014-07-28 17:48:41.050
C) SELECT SYSDATETIME()
2014-07-28 17:48:41.050
D) SELECT GETDATE()
2014-07-28 17:48:41.0528876
2. GETDATE is a nondeterministic function. Views and expressions that reference this function in a column ......... be indexed.
A) can
B) cannot
C) can sometimes
D) must
3. Result of the below two queries will be:
SELECT DATEDIFF(week,'2005-12-31 23:59:59.9999999','2006-01-01 00:00:00.0000000');
SELECT DATEDIFF(hour,'2005-12-31 23:59:59.9999999','2006-01-01 00:00:00.0000000');
A) 24, 1
B) 1, 24
C) 1, 1
D) None of the above
4. Result of the below two queries will be:
SELECT DATEDIFF(week, '2005-12-31', '2006-01-01');
SELECT DATEDIFF(hour, '2005-12-31', '2006-01-01');
A) 24, 1
B) 1, 24
C) 1, 1
D) 24, 24
5. If result of the below query
SELECT DATEADD(month, 1, '2006-08-29');
is:
2006-09-29 00:00:00.000
Then what will be returned by below two queries:
SELECT DATEADD(month, 1, '2006-08-30');
SELECT DATEADD(month, 1, '2006-08-31');
A) 2006-09-30 00:00:00.000, 2006-10-01 00:00:00.000
B) 2006-09-30 00:00:00.000, 2006-09-31 00:00:00.000
C) 2006-09-30 00:00:00.000, 2006-10-30 00:00:00.000
D) 2006-09-30 00:00:00.000, 2006-09-30 00:00:00.000
6. Result of the below query will be:
SET DATEFORMAT mdy;
SELECT ISDATE('12/31/208');
A) 0
B) 1
C) 2
D) 3
7. If the result of below query
select CONVERT(VARCHAR(19),GETDATE())
is:
Jul 29 2014 9:46AM
what will be the result of below query:
select CONVERT(VARCHAR(10),GETDATE())
A) Jul 29 2014 9:46AM
B) Jul 29 2014 9 AM
C) Jul 29 2014
D) Jul 29 201
8. If result of below query
select CONVERT(VARCHAR(19),GETDATE())
is:
Jul 29 2014 9:46AM
what will be the result of below query:
select CONVERT(VARCHAR(10),GETDATE(),10)
A) Jul 29 2014
B) 07-29-14 9:46AM
C) 07-29-14
D) Jul 29 201
9. When you convert to date and time data types, SQL Server rejects all values it cannot recognize as dates or times.
A) True
B) False
10. If result of below query
SELECT CAST('2007-05-08 12:35:29' AS smalldatetime)
is:
2007-05-08 12:35:00
What will be the result of this next query:
SELECT CAST('2007-05-08 12:35:30' AS smalldatetime)
A) 2007-05-08 12:31:00
B) 2007-05-08 12:36:00
C) 2007-05-08 12:32:00
D) 2007-05-08 12:30:01
Answers
1. From the below options (queries and their results) choose the correct values returned by SYSDATETIME() and GETDATE(). Which of the below two options are correct:
A) SELECT SYSDATETIME()
2014-07-28 17:48:41.0528876
B) SELECT GETDATE()
2014-07-28 17:48:41.050
C) SELECT SYSDATETIME()
2014-07-28 17:48:41.050
D) SELECT GETDATE()
2014-07-28 17:48:41.0528876
2. GETDATE is a nondeterministic function. Views and expressions that reference this function in a column ......... be indexed.
A) can
B) cannot
C) can sometimes
D) must
3. Result of the below two queries will be:
SELECT DATEDIFF(week,'2005-12-31 23:59:59.9999999','2006-01-01 00:00:00.0000000');
SELECT DATEDIFF(hour,'2005-12-31 23:59:59.9999999','2006-01-01 00:00:00.0000000');
A) 24, 1
B) 1, 24
C) 1, 1
D) None of the above
4. Result of the below two queries will be:
SELECT DATEDIFF(week, '2005-12-31', '2006-01-01');
SELECT DATEDIFF(hour, '2005-12-31', '2006-01-01');
A) 24, 1
B) 1, 24
C) 1, 1
D) 24, 24
5. If result of the below query
SELECT DATEADD(month, 1, '2006-08-29');
is:
2006-09-29 00:00:00.000
Then what will be returned by below two queries:
SELECT DATEADD(month, 1, '2006-08-30');
SELECT DATEADD(month, 1, '2006-08-31');
A) 2006-09-30 00:00:00.000, 2006-10-01 00:00:00.000
B) 2006-09-30 00:00:00.000, 2006-09-31 00:00:00.000
C) 2006-09-30 00:00:00.000, 2006-10-30 00:00:00.000
D) 2006-09-30 00:00:00.000, 2006-09-30 00:00:00.000
6. Result of the below query will be:
SET DATEFORMAT mdy;
SELECT ISDATE('12/31/208');
A) 0
B) 1
C) 2
D) 3
7. If the result of below query
select CONVERT(VARCHAR(19),GETDATE())
is:
Jul 29 2014 9:46AM
what will be the result of below query:
select CONVERT(VARCHAR(10),GETDATE())
A) Jul 29 2014 9:46AM
B) Jul 29 2014 9 AM
C) Jul 29 2014
D) Jul 29 201
8. If result of below query
select CONVERT(VARCHAR(19),GETDATE())
is:
Jul 29 2014 9:46AM
what will be the result of below query:
select CONVERT(VARCHAR(10),GETDATE(),10)
A) Jul 29 2014
B) 07-29-14 9:46AM
C) 07-29-14
D) Jul 29 201
9. When you convert to date and time data types, SQL Server rejects all values it cannot recognize as dates or times.
A) True
B) False
10. If result of below query
SELECT CAST('2007-05-08 12:35:29' AS smalldatetime)
is:
2007-05-08 12:35:00
What will be the result of this next query:
SELECT CAST('2007-05-08 12:35:30' AS smalldatetime)
A) 2007-05-08 12:31:00
B) 2007-05-08 12:36:00
C) 2007-05-08 12:32:00
D) 2007-05-08 12:30:01
Answers