Count the number of a special day between two dates by using PL/SQL
Write a pl/sql program to input two dates and print number of Sundays between those two dates.
Before each iteration of the loop, condition is evaluated. If it evaluates to TRUE, sequence_of_statements is executed. If condition evaluates to FALSE or NULL, the loop is finished and control resumes after the END LOOP statements.
The only difference between simple loop and while loop is simple execute first and then it will check condition, so simple loop execute at least once and in while loop first it will check condition and then execute.
Input: Enter value for date1: 01-SEP-19 Enter value for date2: 29-SEP-19 Output: no of Sundays : 5
Input: Enter value for date1: 01-SEP-19 Enter value for date2: 15-SEP-19 Output: no of Sundays: 3
Enter value for date1: 01-SEP-19 old 5: Begin D1:='&Date1'; new 5: Begin D1:='01-SEP-19'; Enter value for date2: 29-SEP-19 old 6: D2:='&Date2'; new 6: D2:='29-SEP-19'; no of Sundays:5
PL/SQL procedure successfully completed.
By using while loop first it checks condition and then execute, So We count easily the number of a special day between two dates.