跳到主要內容

Excel公式:計算年/月/週/天中兩個日期之間的差異

doc計算時間5之間的差

有時,在Excel工作表中,我們需要計算兩個日期之間的差值以獲取持續時間。 在本教程的此處,它介紹了計算年,月,周和天中兩個日期之間的差的公式。

如果您想學習本教程,請下載示例電子表格。
doc計算時間5之間的差

通用公式:

計算天數差異

DATEDIF(start_date,end_date,"d")

計算週差

DATEDIF(start_date,end_date,"d")/7

計算月份差異

DATEDIF(start_date,end_date,"m")

計算年份差異

DATEDIF(start_date,end_date,"y")

參數

Start_datetime: The starting date in the date range. The start date must be smaller than the end date, or the formula will return the error result #NUM!.
End_datetime: The ending date in the date range you want to calculate the date duration. The end date must be greater than the start date, otherwise the formula will return the error value #NUM!.
D: Return difference in days.
D/7:Return difference in weeks. 7 days a week, to return days firstly then divides 7 to get the number of weeks. As the formula returns value in date format, you need to format the result to general or number to get the number of weeks.
M: Return difference in months.
Y: Return difference in years.

這個公式如何運作

假設您需要計算單元格B4和B6中日期之間的持續時間,請使用以下公式

計算天數差異

=DATEDIF(B4,B6,"d")

計算週差

=DATEDIF(B4,B6,"d")/7

計算月份差異

=DATEDIF(B4,B6,"m")

計算年份差異

=DATEDIF(B4,B6,"y")

媒體推薦 Enter 獲得結果的關鍵。

提示:以星期為單位計算差異的公式將以日期格式獲得結果,只需根據需要將結果單元格設置為常規或數字格式。
doc計算時間5之間的差

解釋

DATEDIF功能:此函數用於計算以天,週,月,年,忽略年的天或忽略年的月的兩個日期之間的差。


相對公式

相關功能


最佳辦公效率工具

Kutools for Excel-幫助您從人群中脫穎而出

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項  |  刪除空白行  |  合併列或儲存格而不遺失數據  |  沒有公式的回合 ...
超VLookup: 多重標準  |  多重價值  |  跨多頁  |  模糊查詢...
副詞。 下拉清單: 簡易下拉列表  |  依賴下拉列表  |  多選下拉列表...
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  將列與 選擇相同和不同的單元格 ...
特色功能: 網格焦點  |  設計圖  |  大方程式酒吧  |  工作簿和工作表管理器 | 資源庫 (自動文字)  |  日期選擇器  |  合併工作表  |  加密/解密單元格  |  按清單發送電子郵件  |  超級濾鏡  |  特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符 ...)  |  50+ 圖表 類型 (甘特圖 ...)  |  40+ 實用 公式 (根據生日計算年齡 ...)  |  19 插入 工具 (插入二維碼, 從路徑插入圖片 ...)  |  12 轉化 工具 (數字到單詞, 貨幣兌換 ...)  |  7 合併與拆分 工具 (高級合併行, 拆分 Excel 儲存格 ...)  |  ... 和更多

Kutools for Excel 擁有超過 300 個功能, 確保只需點擊一下即可獲得您所需要的...

產品描述


Office選項卡-在Microsoft Office(包括Excel)中啟用選項卡式閱讀和編輯

  • 一秒鐘即可在數十個打開的文檔之間切換!
  • 每天為您減少數百次鼠標單擊,告別鼠標手。
  • 查看和編輯多個文檔時,將您的工作效率提高 50%。
  • 為 Office(包括 Excel)帶來高效的選項卡,就像 Chrome、Edge 和 Firefox 一樣。
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations