跳到主要內容

如何在Excel中將時間字符串轉換為時間?

例如,您在工作表中有一個文本字符串列表,現在您需要將這些文本字符串轉換為時間或日期和時間,如何解決? 在這裡,我將向您介紹一些技巧,以快速將文本字符串轉換為Excel中的時間。

將文本字符串轉換為時間

將文本字符串轉換為日期和時間


箭頭藍色右氣泡 將文本字符串轉換為時間

要將文本字符串轉換為時間,可以使用一些公式來求解。

1.選擇一個單元格並鍵入此公式 = TIMEVALUE(LEFT(A1,LEN(A1)-2)&“:”&RIGHT(A1,2)) (A1是您需要轉換為時間的文本字符串),然後按 Enter。 如果需要,可以將填充手柄拖到所需的範圍。 看截圖:
文檔時間字符串到時間 1

2.然後右鍵單擊這些選定的單元格,然後選擇 單元格格式 從上下文菜單中,然後在 單元格格式 對話框中選擇 Time 來自 類別 在下面列出 聯繫電話 標籤,然後選擇所需的時間類型。
文檔時間字符串到時間 2

3。 點擊 OK,現在文本字符串將轉換為時間。
文檔時間字符串到時間 3

注意:

1.當包含秒的文本字符串(例如120158)時,此公式無法正常工作。

2.如果您的文本字符串格式為120456P,則可以使用此公式 =TEXT(--(LEFT(A1,LEN(A1)-1)),"0\:00\:00")+((RIGHT(A1,1)="P")/2),然後將單元格設置為您需要的12小時制。 看截圖:

文檔時間字符串到時間 4
文檔時間字符串到時間 5

箭頭藍色右氣泡 將文本字符串轉換為日期和時間

如果您的文本字符串包含日期和時間(例如20141212 0312),則可以使用一些長公式來解決。

1.在空白單元格中,鍵入此公式 =DATE(LEFT(A1,4),MID(A1,5,2),MID(A1,7,2))+TIME(MID(A1,10,2),RIGHT(A1,2),0),然後按 Enter 鍵,如果需要,可以將此公式應用於範圍。

2.然後右鍵單擊選定的單元格,然後選擇 單元格格式 從上下文菜單中,然後在 單元格格式 對話框中選擇 日期 來自 類別 列表,然後從右側選擇所需的類型。
文檔時間字符串到時間 6

3。 點擊 OK。 現在您可以看到文本字符串轉換為日期和時間。
文檔時間字符串到時間 7

小費。如果要將時間轉換為十進制小時,分鐘或秒,請嘗試使用 Excel的Kutools轉換時間 如以下屏幕截圖所示。 它在30天內無限制地提供完整功能, 請下載並立即免費試用。

在Excel中快速將時間轉換為十進制值

例如,您有一個需要轉換為十進制小時,分鐘或秒的時間列表,如何在Excel中快速輕鬆地解決該問題? 的 轉換時間 of Kutools用於 Excel,可以為您幫個忙。   點擊免費試用30天!
doc轉換時間
 
Kutools for Excel:擁有300多個便捷的Excel加載項,可以在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 (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Would love any help with this. I have data that is reported as "1d 01h 01m" representing 1 day, 1 hour, 1 min and I need to be able to represent this as a single number (preferably in # of minutes) any thoughts on how I can convert this string to a number value? Thanks all!
This comment was minimized by the moderator on the site
how to convert 06Hr:11Mi into 06:11
This comment was minimized by the moderator on the site
Hi, abinash kumar, you can remove alpha characters from your time string.
This tutorial can help you:
How to remove alpha characters from cells in Excel?
This comment was minimized by the moderator on the site
how do I convert Date/Time with this text format 08/07/2022 1519
This comment was minimized by the moderator on the site
Hi, Tina, please give me a specific example for explaining and descriping your problem. Thank you.
This comment was minimized by the moderator on the site
Hi there!

I used one of formulas above to convert a time string and it worked beautifully expect for anything that had a format of 1200P. It should convert to 12:00 but instead converts to 00:00. Any thoughts on why or how to fix it?

I used: "120456P, you can use this formula =TEXT(--(LEFT(A1,LEN(A1)-1)),"0\:00\:00")+((RIGHT(A1,1)="P")/2)"

I did not have any seconds in my time string so I deleted the last set of 0's in the formula and it still worked.
This comment was minimized by the moderator on the site
Hi.,I have a query.
I want to convert a duration extracted in a format #h #m #s to duration format so that I can filter it. For example:
My data has a field named Session Duration and the format of the cell is "General" and the cell says "1h 2m 15s". I need to convert this data into 01:02:15 but not in time format but a duration. Is there a way to do that.
This comment was minimized by the moderator on the site
=A1/(24*60) (algebra methods)..hahhaha
then apply time format
This comment was minimized by the moderator on the site
How can I convert 1 Hour 35 Min 25 Sec, stored as a text format into Hour format (hh:nn:ss)?
This comment was minimized by the moderator on the site
Hi, Gabriel, you can try this formula =TIME(LEFT(K4,1),MID(K4,8,2),MID(K4,15,2)) K4 is the cell contains text you want to convert, then format the result as time.
This comment was minimized by the moderator on the site
2h 50m how do i convert into 2:50
This comment was minimized by the moderator on the site
Hi, Ayaan, you can try Find and Replace function, h (blank) replace wth : , m replace with nothing
This comment was minimized by the moderator on the site
using the [ =TEXT(--(LEFT(A1,LEN(A1)-1)),"0\:00\:00")+((RIGHT(A1,1)="P")/2) ] formula,
in example #2 above, 123706A >> gets converted to 12:37:06 PM (instead of 12:37:06 AM)
how may this be rectified?
This comment was minimized by the moderator on the site
You only need to change the P to A in the formula =TEXT(--(LEFT(A1,LEN(A1)-1)),"0\:00\:00")+((RIGHT(A1,1)="A")/2), the format the formula cell as hh:mm:ss AM/PM
This comment was minimized by the moderator on the site
so if you enter 35943A you get 3:59:43 AM (which is great).
but if you enter 123706A you would expect to get 12:37:06 AM but instead you get 12:37:06 PM (which is not so great).
also if you enter 123706P you get 12:37:06 AM (again expecting to get 12:37:06 PM).
the meridiem are only incorrect for 12xxxx, formula works flawlessly for 1~11.
any way to improve the formula, to be all encompassing? thank you
This comment was minimized by the moderator on the site
It is a little complex, sorry I cannot help you. Maybe someone in our forum https://www.extendoffice.com/forum.html can help you if you place the question in it.
This comment was minimized by the moderator on the site
using the [ =TEXT(--(LEFT(A1,LEN(A1)-1)),"0\:00\:00")+((RIGHT(A1,1)="P")/2) ] formula,
in example #2 above, 123706A >> gets converted to 12:37:06 PM (instead of 12:37:06 AM)
how may this be rectified?
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