简体   繁体   English

Excel公式:获取当月的年初至今工作日计数

[英]Excel Formula: Get Year to Date Workday Count in Current Month

I need a formula that gives me the YTD workday count for each month. 我需要一个公式,该公式可以为我提供每个月的年初至今工作日计数。

For example: 例如:

If today is 8/6/2015 - the workday count should be 17 (excluding weekends) If today is 9/3/2015- the workday count should be 18 (excluding weekend and 1 holiday) 如果今天是2015年8月6日-工作日数应为17(不包括周末)如果今天是2015年9月3日-工作日数应为18(不包括周末和1假期)

Thanks, 谢谢,

This is just the native Excel function: 这只是本机Excel函数:

=NETWORKDAYS(TODAY(),DATE(YEAR(TODAY()),MONTH(TODAY()),31))

Note that you will need to choose a set of holidays to exclude from the working days function, and define that as a Name in the Formula Ribbon -> Name Manager. 请注意,您将需要选择一组假期从工作日功能中排除,并将其定义为“公式功能区”->“名称管理器”中的“名称”。 ie: 即:

=NETWORKDAYS(TODAY(),DATE(YEAR(TODAY()),MONTH(TODAY()),31),CustomHolidays)

Where CustomHolidays has been defined as a name which means: 其中CustomHolidays已定义为名称,这意味着:

={02/14/2015;03/15/2015;...} = {02/14/2015; 03/15/2015; ...}

You need NETWORKDAYS between the first of the month, and the last of the month. 您需要在每月的第一天到最后一个月之间的NETWORKDAYS。

Assuming your date is in A2, first of the month is simple, A2-DAY(A2)+1. 假设您的日期在A2中,那么每月的第一天很简单,即A2-DAY(A2)+1。 Last of the month is harder as it could be 28, 29, 30 or 31. Youy can use EOMONTH to get this though, EOMONTH(A2,0) 这个月的最后一天会比较困难,因为可能是28、29、30或31。您可以使用EOMONTH来获得此值,EOMONTH(A2,0)

Put it all together 放在一起

=NETWORKDAYS(A2-DAY(A2)+1,EOMONTH(A2,0))

As has been commented, you can also include holidays if you wish to exclude these. 如前所述,如果您希望排除假期,则还可以包括假期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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