Wednesday, 26 November 2014

how to write a sql query for Number of working days between any 2 given dates.?

The working days means count of days other then Saturdays and Sundays. Let us take the given 2 dates as ’dd-mm-yyyy′ and SYSDATE.
and your result will be look like 
select count(val) Number_of_working_days from
(
select
to_number(to_char(to_date(’dd-mm-yyyy′)+rownum , ’D')) val,
to_char(to_date(’dd-mm-yyyy′)+ rownum) date1,
to_char(to_date(’dd-mm-yyyy′) + rownum, ‘Day’) day1
from
all_objects
where
to_date('dd-mm-yyyy')+rownum<= sysdate
)
where val not in (6,7)
Thanks
Hari


1 comment:

  1. Thank you so much for highlighting the solution to this complex problem the answer of which people always struggle to find out.

    Informatica Read JSON

    ReplyDelete