Question: Create a function that will accept a date as input and will return if the date falls on a weekday or on a weekend. Before

Create a function that will accept a date as input and will return if the date falls on a weekday or on a weekend. Before you start writing this function experiment with queries below.

Current date

(select sysdate from dual;

Yesterday

select sysdate - 1 from dual;

Tomorrow

select sysdate + 1 from dual;

The date format element D returns the number of the day of the week (1-7).

select to_char(sysdate,'D') from dual;

MM returns two-digit numeric abbreviation of month (01-12; JAN = 01)

select to_char(sysdate,'MM') from dual;

Example of the output

Create a function that will accept a date as input and will

SET SERVEROUTPUT ON: SELECT uork_or_not('24-JAN-2017') FROM dual; SELECT work_or_not( '25-JAN-2017 FRO dual; SELECT work_or_not ('17-HAR-2017) FROM dual; Script Output x> Query Result x 4 Task completed in 0 seconds FUNCTION WORK OR_NOT compiled ORK_OR_NOT ('24-JAN-2017') 24-JAN-17 is a work day WORK-OR-NOT( 125-JAN-2017' ) 25-JAN-17 is a uork day. ORK_OR_NOT (' 17-MAR-2017')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!