Workshop

Team-Fly    

 
Sams Teach Yourself SQL in 24 Hours, Third Edition
By Ronald R. Plew, Ryan K. Stephens
Table of Contents
Hour  12.  Understanding Dates and Times


The following workshop is composed of a series of quiz questions and practical exercises. The quiz questions are designed to test your overall understanding of the current material. The practical exercises are intended to afford you the opportunity to apply the concepts discussed during the current hour, as well as build upon the knowledge acquired in previous hours of study. Please take time to complete the quiz questions and exercises before continuing. Refer to Appendix C,"Answers to Quizzes and Exercises," for answers.

Quiz

1:

From where is the system date and time normally derived?

2:

List the standard internal elements of a DATETIME value.

3:

What could be a major factor concerning the representation and comparison of date and time values if your company is an international organization?

4:

Can a character string date value be compared to a date value defined as a valid DATETIME data type?

Exercises

1:

Type the following SQL code into the mysql> prompt to display the current date from the MySQL server:

  SELECT CURRENT_DATE;  
2:

Type the following SQL code into the mysql> prompt to display each employee's hire date:

  SELECT EMP_ID, DATE_HIRE   FROM EMPLOYEE_PAY_TBL;  
3:

In MySQL, dates can be displayed in various formats using the EXTRACT function in conjunction with the MySQL date pictures. Type the following code to display on the year that each employee was hired :

  SELECT EMP_ID, EXTRACT(YEAR FROM DATE_HIRE)   FROM EMPLOYEE_PAY_TBL;  
4:

Type the following code to display the current date along with the date that each employee was hired:

  SELECT EMP_ID, DATE_HIRE, CURRENT_DATE   FROM EMPLOYEE_PAY_TBL;  
5:

On what day of the week was each employee hired?

6:

What is today's Julian date (day of year)?


Team-Fly    
Top
 


Sams Teach Yourself SQL in 24 Hours
Sams Teach Yourself SQL in 24 Hours (5th Edition) (Sams Teach Yourself -- Hours)
ISBN: 0672335417
EAN: 2147483647
Year: 2002
Pages: 275

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net