Answer to Question #299818 in Databases | SQL | Oracle | MS Access for Sharanya

Question #299818

Write a PL/SQL program to check whether a date falls on weekend i.e. SATURDAY or SUNDAY input give input as 5sep 1984

1
Expert's answer
2022-02-20T07:00:45-0500

DECLARE

dt1 DATE := TO_DATE('&new_dt', 'DD-MON-YYYY');

get_day VARCHAR2(15);

BEGIN

get_day := RTRIM(TO_CHAR(dt1, 'DAY'));

IF get_day IN ('SATURDAY', 'SUNDAY') THEN

dbms_output.new_line;

DBMS_OUTPUT.PUT_LINE 

('The day of the given date is '||get_day||' and it falls on weekend');

ELSE

dbms_output.new_line;

DBMS_OUTPUT.PUT_LINE ('The day of the given date is '||get_day||' and it does not fall on the weekend');

END IF;

DBMS_OUTPUT.PUT_LINE ('Execution done successfully.');

END;

/



Enter value for new_dt: 5-SEPTEMBER-1984
old   2: dt1 DATE := TO_DATE('&new_dt', 'DD-MON-YYYY');
new   2: dt1 DATE := TO_DATE('5-SEPTEMBER-1984', 'DD-MON-YYYY');

The day of the given date is SATURDAY and it falls on weekend
Execution  done successfully.

PL/SQL procedure successfully completed.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS