跳到主要内容

如何计算Excel中两个日期之间的天数,工作日和周末?

您是否曾经需要计算过Excel中两个日期之间的天数? 有时,您可能只想计算两个日期之间的工作日,有时,您只需要计算两个日期之间的周末天。 在特定条件下,您如何计算两个日期之间的天数?


用公式计算或计算两个日期之间的天数

要计算两个给定日期之间有多少天,请应用以下任一公式:

=DATEDIF(A2,B2,"D")
= B2-A2

然后按 输入 键,您将获得两个日期之间的天数。 看截图:

备注:在以上公式中, A2 指示开始日期,以及 B2 指示结束日期。 您可以根据需要替换它们。


用公式计算或计算两个日期之间的工作日数

但是有时候,您只想找出工作日的数量(从星期一到星期五),上面的公式对您不起作用。 在这种情况下,以下两个功能可以帮助您解决此问题。


1.使用NETWORKDAYS函数计算工作日数

在空白单元格中,请输入以下公式:

=NETWORKDAYS(A2,B2)

然后键入 输入 键,您将计算两个日期之间的工作日数(不包括星期日和星期六)。 看截图:

备注:在以上公式中, A2 指示开始日期,以及 B2 指示结束日期。


2.使用NETWORKDAYS函数计算工作日数,但不包括假期

有时,两个日期之间可能会有一些假期,如果要计算这两个日期之间的工作日,则应排除周六,周日和节假日。 这个 NETWORKDAYS 功能也可以帮助您。

的语法 NETWORKDAYS 功能是: = NETWORKDAYS(开始日期,结束日期,假日)

在要从日期中减去的单元格中输入假期日期,然后在要获取结果的空白单元格中输入以下公式:

=NETWORKDAYS(A2,B2,$C$2:$C$6)

然后按 输入 键,计算出不包括周日,周六和节假日的工作日数。 看截图:

备注:在以上公式中, A2 表示开始日期, B2 代表结束日期, C2:C6 是假期的清单。


3.使用SUM和INT函数计算工作日数

除了NETWORKDAYS函数外,还有另一个公式可以帮助您获取两个日期之间的工作日数。

在空白单元格中,输入或复制以下公式:

=SUM(INT((WEEKDAY(A2-{2,3,4,5,6})+B2-A2)/7))

然后点击 输入 键,将计算所有工作日。 看截图:

笔记:

1.有时,您每周有6个工作日(从周一到周六),因此您需要计算工作日的数量,包括周六,但不包括周日。 在这种情况下,您可以应用以下公式:

=SUM(INT((WEEKDAY(A2-{2,3,4,5,6,7})+B2-A2)/7))

2.在上述公式中, A2 代表开始日期, B2 指示结束日期。


使用公式计算或计算两个日期之间的周末天数

这里也有一些公式,可以只计算给定期间内周末(周六和周日)的天数。 请输入或复制以下两个公式之一:

=SUMPRODUCT(--(WEEKDAY(ROW(INDIRECT(A2&":"&B2)),2)>5))
=SUM(INT((WEEKDAY(A2-{1,7})+B2-A2)/7))

然后按 输入 键,现在您将获得两个日期之间的多少个周末。 看截图:

备注:在以上公式中, A2 表示开始日期, B2 代表结束日期。


有用的功能可计算或计算两个日期之间的工作日,周末数

要计算两个给定日期之间的工作日或周末的数量, Kutools for Excel公式助手 该实用程序包含一些常用公式,您可以应用它们来计算年龄,单词出现等。

请注意:申请这个 公式助手,首先,您应该下载 Kutools for Excel,然后快速轻松地应用该功能。

安装后 Kutools for Excel,请这样做:

1。 单击要在其中查找结果的单元格,然后单击 库工具公式助手 > 公式助手,请参见屏幕截图:

2。 在 公式助手 对话框中,进行以下操作:

  • 选择 统计 选项从 公式 Type 落下;
  • 选择一个公式 列表框,选择 两个日期之间的非工作天数 or 两个日期之间的工作天数 您想使用;
  • 然后,在“参数输入”部分中,分别选择包含开始日期和结束日期的单元格。
  • 最后点击 Ok 按钮以得到如下所示的结果:


计算或计算两个日期之间的天数,周数,月数或年数

Kutools for Excel's 日期和时间助手 功能,您可以根据需要快速获得两个日期之间的各种差异结果,而无需记住任何公式,例如周+天,月+周等。 点击下载Kutools for Excel!

Kutools for Excel:具有300多个方便的Excel加载项,可以在30天内免费试用,没有任何限制。 立即下载并免费试用!


更多有关日期和时间的文章:

  • 在Excel中计算午夜后的时间之间的小时数
  • 假设您有一个时间表来记录您的工作时间,则A列中的时间是今天的开始时间,B列中的时间是第二天的结束时间。 通常,如果您直接减去“ = B2-A2”来计算两次之间的时间差,则不会显示正确的结果,如左图所示。 如何在Excel中正确计算午夜后两次之间的小时数?

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (51)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I am trying to work out how many days worked in a week but I have number of hours worked in the cells. Plus RD as a rest day. is there any way for this to be done rather than manual input
This comment was minimized by the moderator on the site
I am curious if there is a way to have excel do a rolling countdown between dates. Our fiscal year year is 10/1 to 09/30. I figured out how to show how many working days there is between these dates, but now I need to have that number decrease with each passing day. That way each Friday when we open the spreadsheet, it will tell us how many days are left. Is this possible?
This comment was minimized by the moderator on the site
Witam,
chcialabym uzyskać wynik w jednej KOMÓRCE: ZAKRES DAT - czyli np. 08.sie-15.wrz - dane natomiast maja sie zaciagac z innego XLS, w którym zaznaczane jedynkami sa dni urlopu w komórkach poszczeólnych dni. Kolumny w pliku źródłowym to: (scalona komórka MIESIĄCA (sty, lut, mar itp) poniżej są w komórkach wszytskie dni miesiaća 1-31, scalona komorka miesiaca zawiera pod soba wsyztskie te dni
ponizej wiersze dotycza pracowników i w kolejnych kolumnach uzupełniane są JEDNKI - oznaczające wzięcie urlopu w tym dniu....
chciałbym żeby te jedynki były wyciągane z pliku źródłowego tak, aby wynik był zakresem daty....

Czy to jest możliwe?
This comment was minimized by the moderator on the site
Hi,

Can you help me make a formula counting the number of days of work in a week excluding Sundays and holidays, please note Saturday is only a half day of work.

Also I wanted to create a formula to calculate the allowed number of days of leave for employees using the sum of number of year/month/day of service work multiple by 2 working days per month (leave provision per month).

I got a hard time making a formula about this
This comment was minimized by the moderator on the site
i have one date, lets say 6/18/2020, i need it has to be minus exact 1 month(5/18/2020), if the result date 5/18/2020 is belongs to saturday or sunday than it would be FRIDAY's date. could you please give the formula for it. - Ramu
This comment was minimized by the moderator on the site
HI,
I NEED TO CALCULATE NUMBER OF DAYS BETWEEN TODAY FROM A STARTING DATE .
This comment was minimized by the moderator on the site
Hi, RAJIH,
You can also use this formula: =DAYS(TODAY(), A2), A2 is the cell contains your starting date, please try, hope it can help you!
Thank you!
This comment was minimized by the moderator on the site
Type your starting date in any cell of excel.
Type today date in another cell of excel.
Now simply minus the starting date from today date.
Example: Starting date is in cell A1, Today date is in cell A2. Simply type =A2-A1.
This comment was minimized by the moderator on the site
What about about adding days from a date, for example: 3/4/19 then add 60 days to get a new date.
This comment was minimized by the moderator on the site
Hello,

To add some days to a date, you just need to add the days to the date directly as below formula:
=A1+60
Please try it, hope it can help you!
This comment was minimized by the moderator on the site
HI,
need formula for calculate the days for working days (monday,tuesday, wednesday, thursday and Saturday) - minus holidays. (weekends is friday and sunday)

pls help.
This comment was minimized by the moderator on the site
Offday Friday and Saturday
Public Holiday 22/08/18, 23/08/2018
Manual count for working day are 20 days.
=SUM(INT((WEEKDAY(L3-{1,2,3,4,5})+L5-L3)/7)) --->Total working day 22
=NETWORKDAYS(L14,L16,L18:BS19) -->Total working days 21

Please help
This comment was minimized by the moderator on the site
I need formula for 22 working days (Saturday and Sunday OFF)consider in every moth by selecting date range if 21 working days come in a month but considered 22 and if 23 working days come but also considered 22. so please give me any suggestion ?

This comment was minimized by the moderator on the site
I always have Start Date, with set number of working days to complete various activities.

=WORKINGDAY.INTL(START,DAYS,WEEKEND,HOLIDAYS) also causes issues, we work Sun-Thu, so weekend option is 7, yet this formula isn't consistent either, May 2019 has 22 working days (DAYS), this makes the result 02-Jun-19, which is the 2nd working day of June!

Yet same formula for June 2019 with 21 working days gives the expected answer of 30-June-19.
This comment was minimized by the moderator on the site
Hi i need an excel formula which calculates the number of days between two dates and will give me a warning if the count is past day 28. Also if day 28 falls on a weekend or public holiday then the formula needs to account for this so day 28 becomes the next business day.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations