跳到主要內容

如何在Excel中將數字轉換為年/月/日或日期?

我們可以輕鬆地在Excel中計算兩個日期之間的天數,但是如何將天數顯示為年/月/日,例如“1年4個月25天“?如果將數字yyyymmdd轉換為正常日期該怎麼辦?本文討論的是將數字轉換為年/月/日或Excel中的日期。


將數字(天)轉換為年/月/日

此方法將引入一個公式,將天數轉換為年/月/日,例如“1年4個月25天在Excel中。”,請執行以下操作:

1。 選擇一個空白單元格,您將輸出轉換結果,並在其中輸入以下公式,然後按 Enter 鍵。

= DATEDIF(0,A2,“ y”)&“年”&DATEDIF(0,A2,“ ym”)&“月”&DATEDIF(0,A2,“ md”)&“天”

注意:A2是您要轉換為年/月/日的天數的單元格。

2。 繼續選擇轉換結果的單元格,然後根據需要將其“填充手柄”拖動到範圍內。 然後,您將看到所有數字都轉換為年/月/日。 看截圖:

只需單擊一下即可刪除所有公式,但保留多個單元格中的計算值


Excel的Kutools - 使用 300 多種基本工具增強 Excel 功能。 享受全功能 30 天免費試用,無需信用卡! 立即行動吧!

使用出色的工具將數字(天)轉換為年/月/日

有些用戶可能很難記住在Excel中將天數轉換為年/月/日的公式。 在這裡,我建議使用Kutools for Excel的公式助手來快速完成對話,而無需記住痛苦的公式。

Excel的Kutools - 包含 300 多個 Excel 基本工具。 享受全功能 30 天免費試用,無需信用卡! 現在下載!

1。 選擇您要將計算結果放在的單元格,然後單擊 庫工具 > 公式助手 > 公式助手 啟用該功能。

2。 在“公式幫助器”對話框中,請選擇 日期 來自 公式類型 下拉列表,單擊以突出顯示 將天轉換為年月日 ,在 選擇一個公式 列錶框,然後在 聯繫電話 框,最後單擊 Ok 按鈕。

現在,計算結果將輸出到所選單元格中。 如有必要,您可以拖動此單元格的“自動填充手柄”以將此公式複製到其他單元格。

將通用數字轉換為默認日期格式的日期

有時,您將日期鍵入或粘貼到Excel中,但是日期顯示為5位數的通用數字。 在這種情況下,您可以使用以下方法輕鬆地將5位數的通用數字轉換為日期:

選擇5位數字,然後單擊 首頁 > 數字格式 盒子> 短期約會。 然後,您將看到所有選定的5位數字立即轉換為具有默認日期格式的日期。


使用自定義日期格式將通用數字轉換為日期

Kutools for Excel的 套用日期格式 實用程序可以幫助您使用自定義日期格式將5位數字快速轉換為日期。

Excel的Kutools - 包含 300 多個 Excel 基本工具。 享受全功能 30 天免費試用,無需信用卡! 現在下載!

1。 選擇5位數的數字,然後單擊 庫工具 > 格式 > 套用日期格式.

2.在打開的“應用日期格式”對話框中,選擇要在 日期格式 框中,然後單擊 Ok 按鈕。 然後,您將看到所有數字都以指定的日期格式轉換為日期。 看截圖:


一鍵將數字yyyymmdd轉換為日期

有時,您可能會得到yyyymmdd的一些特殊數字,例如20151215。本節將向您展示一種簡單的方法,只需單擊一下即可將yyyymmdd的這些數字轉換為正常日期。 轉換為日期 Kutools for Excel實用程序。

Excel的Kutools - 包含 300 多個 Excel 基本工具。 享受全功能 30 天免費試用,無需信用卡! 現在下載!

選擇具有特殊編號yyyymmdd的單元格,然後單擊 庫工具 > 內容 > 轉換為日期。 看截圖:

然後,您將看到所有選定的數字都與正常日期一致。 看截圖:

請點擊 關閉 按鈕關閉“轉換為日期”對話框。


演示:在Excel中將數字轉換為日期


Excel的Kutools:超過 300 個方便的工具觸手可及! 立即開始 30 天免費試用,沒有任何功能限制。 現在就下載!

相關文章:

最佳辦公生產力工具

🤖 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 (24)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
=YIL(B6)-YIL(A6) & " Yıl " & EĞER(AY(B6)>AY(A6);AY(B6)-AY(A6);AY(A6)-AY(B6)) & " Ay " & EĞER(GÜN(B6)>GÜN(A6);GÜN(B6)-GÜN(A6);GÜN(A6)-GÜN(B6)) & " Gün " bu şekil negatif işareti kaldırabilirsiniz:
This comment was minimized by the moderator on the site
Hi i have one doubt could you say please I want to return as 5.6 years in excel how i can write
This comment was minimized by the moderator on the site
I'm used the formula at the beginning of this topic to calculate how long my employees have worked so I can setup quarterly progress reviews with them. I have the number generated from a formula that gives me how many days from hire date until current date. What is the change in the formula to go from Hire date to the brake down of year/month/day?
This comment was minimized by the moderator on the site
In my situation, I wanted years and months if possible; if not, I wanted just months or just days. I ended up with:
=IF(cellcontainingdays="","",IF(DATEDIF(0,cellcontainingdays,"y")=0,"",CONCATENATE(DATEDIF(0,cellcontainingdays,"y")," years")) & IF(DATEDIF(0,cellcontainingdays,"ym")=0,"",IF(AND(DATEDIF(0,cellcontainingdays,"ym")<>0,DATEDIF(0,cellcontainingdays,"y")=0),CONCATENATE(DATEDIF(0,cellcontainingdays,"ym")," months"),CONCATENATE(", ",DATEDIF(0,cellcontainingdays,"ym")," months"))) & IF(DATEDIF(0,cellcontainingdays,"md")=0,"",IF(AND(DATEDIF(0,cellcontainingdays,"md")<>0,DATEDIF(0,cellcontainingdays,"y")=0,DATEDIF(0,cellcontainingdays,"ym")=0),CONCATENATE(DATEDIF(0,cellcontainingdays,"md")," days"),"")))
This comment was minimized by the moderator on the site
=IF(DATEDIF(0;A1;"y")=0;"";DATEDIF(0;A1;"y")&" year(s), ") & IF(DATEDIF(0;A1;"ym")=0;"";DATEDIF(0;A1;"ym")&" month(s), ") & IF(DATEDIF(0;A1;"md")=0;"";DATEDIF(0;A1;"md")&" day(s)")
This comment was minimized by the moderator on the site
How to handle negative numbers?

it gives #NUM! error.
This comment was minimized by the moderator on the site
Hi Ahmed,

what about changing the negative numbers to positive with ABS function, and then adding minus sign before the whole formula?
This comment was minimized by the moderator on the site
I love you guys.
This comment was minimized by the moderator on the site
Is there a way to automatically omit 0 values? For example, if the formula returns "0 years, 7 months, 16 days", is there a way for it to show up as "7 months, 16 days" instead?
This comment was minimized by the moderator on the site
=IFERROR(IF(DATEDIF(0,M2,"y")>0,DATEDIF(0,M2,"y")&" Years ","")&IF(DATEDIF(0,M2,"ym")>0,DATEDIF(0,M2,"ym")&" Months ","")&IF(DATEDIF(0,M2,"md")>0,DATEDIF(0,M2,"md")&" Days",""),"")
This comment was minimized by the moderator on the site
=IF(DATEDIF(0;A1;"y")=0;"";DATEDIF(0;A1;"y")&" year(s), ") & IF(DATEDIF(0;A1;"ym")=0;"";DATEDIF(0;A1;"ym")&" month(s), ") & IF(DATEDIF(0;A1;"md")=0;"";DATEDIF(0;A1;"md")&" day(s)")
This comment was minimized by the moderator on the site
=IFERROR(IF(DATEDIF(0,M2,"y")>0,DATEDIF(0,M2,"y")&" Years ","")&IF(DATEDIF(0,M2,"ym")>0,DATEDIF(0,M2,"ym")&" Months ","")&IF(DATEDIF(0,M2,"md")>0,DATEDIF(0,M2,"md")&" Days",""),"")
This comment was minimized by the moderator on the site
=CONCATENATE(IF(INT(A2/365)>0,CONCATENATE(INT(A2/365)," Years "),""),CONCATEN ATE(IF(INT(MOD( A2,365)/30)>0,C ONCATENATE(INT( MOD(A2,365)/30) ," Months "),""),CONCATEN ATE(IF(MOD(MOD( A2,365),30)>0,C ONCATENATE(MOD( MOD(A2,365),30) ," Days "),""),))) My formula is ok, When you will copy the formula it will contain some space in word CONCATENATE Like C ONCATENATE/CONCATEN ATE. Please correct the word concatenate. Then i think it will work.
This comment was minimized by the moderator on the site
hello, thanks for the feedback but it's still not working, can you please send me your email so i can show you the table am doing ?! maybe some mistake is there. my email is . now my final table will contain number of days, like for example after the calculations the result will be (123) which is number of days so i want to convert it into ( year , month , days ). or if you have a formula to calculate the defferance between two dates and show the results as ( x year , x month , x days ) that would be super. waiting for your feedback and thanks.
This comment was minimized by the moderator on the site
=IF(DATEDIF(A1;A2;"y")=0;"";DATEDIF(A1;A2;"y")&" year(s), ") & IF(DATEDIF(A1;A2;"ym")=0;"";DATEDIF(A1;A2;"ym")&" month(s), ") & IF(DATEDIF(A1;A2;"md")=0;"";DATEDIF(A1;A2;"md")&" day(s)")
This comment was minimized by the moderator on the site
change every ; to ,
This comment was minimized by the moderator on the site
And what table is that ,that you say your doing?
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