Database Practice Exercise: Dates

                    
Several of the following questions refer to a demonstration table named Employee
that includes columns for empno(int width 4), eName(up to 10 characters), job 
(up to 9 characters),manager(int 4), hiredate (type date), and salary
(decimal 7,2)[,deptno (int 2)]. [For background on date functions see chap 9.]
0. Prepare a query that invokes the function current_user() or user(). The 
   tableName DUAL may be used in the FROM clause.
   
   
   
   
1. Try the functions now(), sysdate(), curdate() when accessing today's date 
   from the system. Note the default date format from curdate().

   
   


2. Use datediff(dateFuture,dateNow) to return the number of days between today
   and 12 May 2015 (final exam).
   
   


3. Apply date_format(date,format) to determine the weekday name(%W), the month
   name(%M), and day number (%d) on which our final is to occur.
   

   
      
4. For each employee, find the approximate difference in years completed between
   their hiredate and today's date.


   
   
5. Use date_format(dateStr,format) to show each employee's hiredate in the form
   monthName(%M), dayOfMonth with suffix(%D), and year in 4-digits(%Y').




6. Show the weekday spelled out(code %W) when each employee was hired.




7. Suppose following a purchase today, one is given a payment option
   called "90 days same as cash", use date_add(date, INTERVAL expression unit)
   to determine that exact deadline. Expression unit could be 1 DAY, 2 DAY ....

   

   
8. Express today's date as a "Julian date" (yyyy/ddd). Note that there are 
   specifiers for the Year and for the day of the year in three-digit form(%j). 
   
   
   
9. For practice, apply dayname(date) to find the name of the day of the week 
   for some significant date (e.g. New Years Day, your birthday, ...).