简体   繁体   中英

Calculate annual leave between two dates in Excel

This task seems easy enough yet I just can't figure a way of doing this without resorting to vba.

All I need is to know the number of hours an employee has used up on annual leave, based on a start and end date, and their hours of work.

工作时间

To be more clear, this example shows one employees contracted hours from Monday to Sunday ie they work only Weds, Thurs, and Friday, for 7.5 hours each day. Below shows the start and end date that the employee has chosen to take for annual leave. I need to calculate, based on their contracted hours, how much annual leave is used between the two dates. The answer would be 45 hours in this case.

Here's another approach - I've expanded the days between the start and end dates into an array then used the resulting day numbers to offset into the days of work range

=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1)))

在此处输入图片说明

If you had a list of holiday dates somewhere (say in I3:N3) you could exclude them as follows

=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1))*ISNA(MATCH(ROW(INDIRECT(A6&":"&B6)),I3:N3,0)))

- it is a bit long-winded but the only way I can think of at the moment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM