Q:

Write a PL/SQL program to check whether a date falls on weekend i.e. SATURDAY or SUNDAY

0

Write a PL/SQL program to check whether a date falls on weekend i.e. SATURDAY or SUNDAY.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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;
/

Sample Output:

Enter value for new_dt: 5-MAY-2018
old   2: dt1 DATE := TO_DATE('&new_dt', 'DD-MON-YYYY');
new   2: dt1 DATE := TO_DATE('5-MAY-2018', '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 an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now