跳到主要內容

如何計算Excel中兩個日期之間的天數,工作日和周末?

您是否曾經需要計算過Excel中兩個日期之間的天數? 有時候,您可能只想計算兩個日期之間的工作日,有時,您只需要計算兩個日期之間的周末天。 在特定條件下,您如何計算兩個日期之間的天數?


用公式計算或計算兩個日期之間的天數

要計算兩個給定日期之間有多少天,請應用以下任一公式:

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

然後按 Enter 鍵,您將獲得兩個日期之間的天數。 看截圖:

備註:在以上公式中, A2 指示開始日期,以及 B2 指示結束日期。 您可以根據需要替換它們。


用公式計算或計算兩個日期之間的工作日數

但是有時候,您只想找出工作日的數量(從星期一到星期五),上面的公式對您不起作用。 在這種情況下,以下兩個功能可以幫助您解決此問題。


1.使用NETWORKDAYS函數計算工作日數

在空白單元格中,請輸入以下公式:

=NETWORKDAYS(A2,B2)

然後鍵入 Enter 鍵,您將計算兩個日期之間的工作日數(不包括星期日和星期六)。 看截圖:

備註:在以上公式中, A2 指示開始日期,以及 B2 指示結束日期。


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

有時,兩個日期之間可能會有一些假期,如果要計算這兩個日期之間的工作日,則應排除週六,週日和節假日。 這個 網絡日 功能也可以幫助您。

該語法 網絡日 功能是: = NETWORKDAYS(開始日期,結束日期,假日)

在要從日期中減去的單元格中輸入假期日期,然後在要獲取結果的空白單元格中輸入以下公式:

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

然後按 Enter 鍵,計算出不包括週日,週六和節假日的工作日數。 看截圖:

備註:在以上公式中, A2 表示開始日期, B2 代表結束日期, C2:C6 是假期的清單。


3.使用SUM和INT函數計算工作日數

除了NETWORKDAYS函數外,還有另一個公式可以幫助您獲取兩個日期之間的工作日數。

在空白單元格中,輸入或複制以下公式:

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

然後點擊 Enter 鍵,將計算所有工作日。 看截圖:

筆記:

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))

然後按 Enter 鍵,現在您將獲得兩個日期之間的多少個週末。 看截圖:

備註:在以上公式中, A2 表示開始日期, B2 代表結束日期。


有用的功能可計算或計算兩個日期之間的工作日,週末數

要計算兩個給定日期之間的工作日或週末的數量, Excel的Kutools公式助手 該實用程序包含一些常用公式,您可以應用它們來計算年齡,單詞出現等。

注意:要應用此 公式助手,首先,您應該下載 Excel的Kutools,然後快速輕鬆地應用該功能。

安裝後 Excel的Kutools,請這樣做:

1。 單擊要在其中查找結果的單元格,然後單擊 庫工具公式助手 > 公式助手,請參見屏幕截圖:

2。 在 公式助手 對話框中,進行以下操作:

  • 選擇 統計 選項從 公式 類別 落下;
  • 選擇一個公式 列錶框,選擇 兩個日期之間的非工作天數 or 兩個日期之間的工作天數 您想使用;
  • 然後,在“參數輸入”部分中,分別選擇包含開始日期和結束日期的單元格。
  • 最後點擊 Ok 按鈕以得到如下所示的結果:


計算或計算兩個日期之間的天數,週數,月數或年數

這款獨特的敏感免洗唇膜採用 Moisture WrapTM 技術和 Berry Mix ComplexTM 成分, Excel的Kutools's 日期和時間助手 功能,您可以根據需要快速獲得兩個日期之間的各種差異結果,而無需記住任何公式,例如周+天,月+周等。 點擊下載Kutools for Excel!

Excel的Kutools:具有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選項卡為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