Write a PL/SQL program to check whether a date falls on weekend i.e. SATURDAY or SUNDAY input give input as 5sep 1984
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.
Comments
Leave a comment