May 2000
Intermediate to advanced
594 pages
11h 32m
English
Q: | |
19-10. | I would use a combination of TRUNC and NEXT_DAY, as shown here: DECLARE
first_monday DATE;
BEGIN
first_monday := NEXT_DAY (
TRUNC (SYSDATE, 'MONTH'), 'MONDAY');
DBMS_OUTPUT.PUT_LINE (first_monday);
END;
/ |
Q: | |
19-11. | We’re talking time-zone differences, so the NEW_TIME function should work perfectly well. London is on Greenwich Mean Time, while the folks in Chicago are on Central Standard Time. Here is a function that does the conversion:
|
Q: | |
19-12. | TRUNC to the rescue once again: CREATE OR REPLACE FUNCTION chitime RETURN DATE IS BEGIN RETURN TRUNC (SYSDATE, 'MONTH'); END; / |
Q: | |
19-13. | Well, first you have to truncate the current date/time back to the beginning of the century (which also sets the time component to midnight), then move forward 25 years, make sure you’re on the first day of that year, and move forward nine hours. Here goes: DECLARE
amaze_me DATE;
BEGIN
amaze_me := TRUNC (
ADD_MONTHS (TRUNC (SYSDATE, 'CC'), 25 * 12), 'MONTH') + 9 / 24;
DBMS_OUTPUT.put_line (
TO_CHAR (
amaze_me,
'MM/DD/YY HH24:MI:SS'
)
);
END;
/Isn’t this fun? |
Q: | |
19-14. | The four pieces of information displayed are: 30-JAN-99 -> 28-FEB-99 27-FEB-99 -> 27-MAR-99 31-JAN-99 -> 28-FEB-99 28-FEB-99 -> 31-MAR-99 |
Q: | |
19-15. | Statement (b) describes accurately the behavior ... |