Home » SQL & PL/SQL » SQL & PL/SQL » pl/sql
pl/sql [message #4302] Mon, 25 November 2002 18:42 Go to next message
Dee
Messages: 11
Registered: September 1999
Junior Member
How do I declare a date variable named current_date, and asign SYSDATE to it. Depending on the day of the month, my program should display the following output
DAY OUTPUT
1-10 It is Day<day number> of <month name>.
It is early in the month

11-20 It is Day<day number> of <month name>.
It is middle in the month

21-31 It is Day<day number> of <month name>.
It is nearly the end of the month
You can declare and use additional variables as needed.
Re: pl/sql [message #4303 is a reply to message #4302] Mon, 25 November 2002 21:02 Go to previous messageGo to next message
ctg
Messages: 146
Registered: July 2002
Senior Member
Hope this helps u with your homework:

DECLARE
current_date DATE := SYSDATE;
day_of_month NUMBER := TO_NUMBER(TO_CHAR(current_date,'DD'));
day_of_month NUMBER;
BEGIN
day_of_month := TO_NUMBER(TO_CHAR(current_date,'DD'));
IF day_of_month BETWEEN 1 AND 10 THEN
DBMS_OUTPUT.PUT_LINE('It is early in the month');
ELSIF day_of_month BETWEEN 1 AND 10 THEN
DBMS_OUTPUT.PUT_LINE('It is the middle of the month');
ELSE
DBMS_OUTPUT.PUT_LINE('It is the end of the month');
END IF;
END;
/
Re: pl/sql [message #4333 is a reply to message #4302] Thu, 28 November 2002 05:55 Go to previous message
Barbara Boehmer
Messages: 9091
Registered: November 2002
Location: California, USA
Senior Member
Please click on the link below for my previous response to a similar question:

Previous Topic: oracle sql v.s. sql server sql
Next Topic: Updatable Views
Goto Forum:
  


Current Time: Mon Apr 29 14:36:27 CDT 2024