Working days between two firefighter dates

I need to count working days between two dates in firebird database (ver 2.5)

I have a table (table_date) with workdays (date, day - free / work) and I have another table with start_date and end_date. For example, we have two dates start_date = 2015-04-04 and end_date = 2015-04-10. Day 2015-04-05 and 2015-04-06 are free. There are 6 days between these dates, but 4 business days.

how to calculate it in the database?

+3


source to share


1 answer


Based on the information you provided, I would suggest that something like this should work:



select a.start_date, a.end_date, 
   (select count(*)
    from working_days
    where "DATE" between a.start_date and a.end_date
    and "DAY" = 'working') as nr_of_workdays
from start_end a

      

+1


source







All Articles