How to Count Working Days on Specific Date

Email This Post Email This Post

For you who need to count how many working days in specific date, i’ll show you how to do this sql query. Its very simple.
Lets says that you have 2 parameters :
1. :p_start_date => for start date
2. :p_end_date => for end date
Both are date format.
The first thing that you need to do is to select / convert these date param into date records :

select :p_start_date+rownum-1 st_date
from user_objects
where :p_end_date+1>=:p_start_date+rownum

I played with user_objects and rownum to convert that 2 date params into date records.

After that you will get date records with that 2 date params. The next thing that you need to do is to exclude SUNDAY dan SATURDAY, cause both is normally holidays ( not working days ) and then count it. So your query will be like :

select count(*) from (
select :p_start_date+rownum-1 st_date
from user_objects
where :p_end_date+1>=:p_start_date+rownum)
where to_char(st_date,’DY’) not in (’SAT’,'SUN’)

Its amazing rite, with view of your sql coding, you will get your working days on specific date. :)
There should be a lot of others ways to generate this kind of query. Do you have any?
Please share with us your technique in below comments.

Popularity: 14% [?]

Related Post

  • No Related Post

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Close
E-mail It