SECTION 1 LESSON 3
1. For DJ on Demand, display the number of months between the event_date of the Vigil wedding and today's date. Round to the nearest month.
where name=Vigil wedding;
2. Display the days between the start of last summer's school vacation break and the day school started this year. Assume 30.5 days per month. Name the output "Days."
----select round(months_between('13-Sep-05','25-Jun-05')*30.5,0) "Day"
3. Display the days between January 1 and December 31.
4. Using one statement, round today's date to the nearest month and nearest year and truncate it to the nearest month and nearest year. Use an alias for each column.
----select round(sysdate,'month') "nearest month", round(sysdate,'year') "nearest year", trunc(sysdate,'month') "Nearest Month", trunc(sysdate,'year') "Nearest Year"
5. What is the last day of the month for June 2005? Use an alias for the output.
6. Display the number of years between the Global Fast Foods employee Bob Miller's birthday and today. Round to the nearest year.
7. Your next appointment with the dentist is six months from today. On what day will you go to the dentist? Name the output, "Appointment."
----select add_months(sysdate,6) as"Appointment"
(Appointment: 24-8月 -06)
8. The teacher said you have until the last day of this month to turn in your research paper. What day will this be? Name the output, "Deadline."
----select last_day(sysdate)as "Deadline"
(Deadline: 28-2月 -06)
9. How many months between your birthday this year and January 1 next year?
10. What's the date of the next Friday after your birthday this year? Name the output, "First Friday."
----select next_day('27-MAY-06','friday')as"First Friday"