跳到主要內容

如何在Excel中將周數轉換為日期,反之亦然?

有沒有一種方法可以在Excel中從給定日期獲取星期數或從特定星期數和年份中提取日期範圍? 要解決此任務,以下公式可能會有所幫助。

使用公式將星期數轉換為日期

使用公式將日期轉換為星期數


使用公式將星期數轉換為日期

假設我在工作表中有一個隨機的年份和星期數,分別是2015和15,如下面的截圖所示,現在我想通過給定的星期數找出星期一到星期日的特定日期。

要通過特定星期數計算日期範圍,可以使用以下公式:

1。 選擇一個空白單元格,您將返回開始日期(在本例中,我們選擇單元格B5),輸入公式: =MAX(DATE(B1,1,1),DATE(B1,1,1)-WEEKDAY(DATE(B1,1,1),2)+(B2-1)*7+1),然後按 Enter 鍵。 請參見下面的屏幕截圖:

2。 選擇另一個空白單元格,您將返回結束日期(在本例中,我們選擇單元格B6),輸入 =MIN(DATE(B1+1,1,0),DATE(B1,1,1)-WEEKDAY(DATE(B1,1,1),2)+B2*7),然後按 Enter 鍵。 請參見下面的屏幕截圖:

注意絲帶 公式太難記了嗎? 將公式另存為“自動文本”條目,以供日後再次使用!
閱讀全文...     免費試用

注意:在上述兩個公式中, B1 包含一年和 B2 是指定的星期數,您可以根據需要更改參數。

3。 如您所見,兩個公式都返回數字而不是日期。 繼續選擇兩個計算結果,然後單擊 首頁 > 數字格式 盒子> 短期約會 將數字更改為日期。 請參見下面的屏幕截圖:

一鍵將多個非標準格式日期/數字/文本轉換為Excel中的正常日期

Kutools for Excel的 轉換為日期 實用程序可幫助您輕鬆地在Excel中一鍵識別和轉換非標準日期或數字(yyyymmdd)或文本為正常日期。


廣告轉換為日期1

使用公式將日期轉換為星期數

另一方面,您也可以應用WEEKNUM函數將日期轉換為相應的星期數。

1。 選擇一個空白單元格,您將返回星期數,輸入以下公式: = WEEKNUM(B1,1),然後按Enter鍵。 看截圖:

筆記:

(1) 在上式中 B1 包含您要使用的日期。

(2) 如果您需要從星期一開始的日期返回星期數,請使用以下公式: = WEEKNUM(B1,2).


相關文章:

如何計算Excel中兩個日期之間的特定工作日數?

如何在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 (24)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
so much complicated.

just hit this one

=TEXT(A2 - (WEEKDAY(A2,2)) + 1, "MMM DD") & " - " & TEXT(A2 + 7 - (WEEKDAY(A2,2)), "MMM DD")
This comment was minimized by the moderator on the site
All of these formulas have issues when the date is in the last week of the year. They don't give the correct date for Monday of the last week.
This comment was minimized by the moderator on the site
I find this better "Start of week"
B5=(8-WEEKDAY(DATE(B1,1,1),1))+((B2-2)*7)+DATE(B1,1,1)

8-WEEKDAY(DATE(B1,1,1),1) => find the no. of days in a week for first week of the year
(B2-2)*7 => calculate the number of days excluding the first week of year and the week for which calculation is being done
Then add these 2 to the first day of the year to get first day of the desired week


Then "End of week",
B6=B5+6

PS:
Week starts on Sunday
For weeks starting on Monday, use this instead:
B5=(8-WEEKDAY(DATE(B1,1,1),2))+((B2-2)*7)+DATE(B1,1,1)
This comment was minimized by the moderator on the site
Your formula works perfectly for every year. End of week would be B6=B5+6 though. Thanks a lot!
This comment was minimized by the moderator on the site
Thanks. Will correct that...
This comment was minimized by the moderator on the site
This formula is overly complicated. If you have a date say 8/17/2021 in Cell A1, to get the Week Ending(as of Saturday) you just need the following: = A1-WEEKDAY(A1,1)+7This will return 8/21/2021. Date of 12/30/2020 will return 1/2/2021 as week ending.
This comment was minimized by the moderator on the site
Hi,

not sure if this has been asked, but essentially, I want to be able to drag the date and the week number automatically fill beside it when I do that.

Can anyone help?

This comment was minimized by the moderator on the site
@gilly2801 you can use an array formula for example with "=weeknum(C2:C)" press command shift enter and it will turn it into an array function.
This comment was minimized by the moderator on the site
Hi please help me.

Suppose we are considering Date 1 to 7 is week 1 and 8 to 14 is week 2. Can you please help me out how can i use if function to calculate week. I have tried but not able to get the correct result.
This comment was minimized by the moderator on the site
=ROUNDUP((TODAY()-DATE(YEAR(TODAY()),1,1))/7,0)
This comment was minimized by the moderator on the site
=ROUNDUP((TODAY()-DATE(YEAR(TODAY()),1,1))/7,0)
This comment was minimized by the moderator on the site
Thank YOU!!!!
This comment was minimized by the moderator on the site
Thank you very much!


=CONCATENATE("Inclusive Dates: ",TEXT(MAX(DATE(TEXT(TODAY(),"yyyy"),1,1),DATE(TEXT(TODAY(),"yyyy"),1,1)-WEEKDAY(DATE(TEXT(TODAY(),"yyyy"),1,1),2)+(WEEKNUM(TODAY())-1)*7+1),"MMMM")," ",TEXT(MAX(DATE(TEXT(TODAY(),"yyyy"),1,1),DATE(TEXT(TODAY(),"yyyy"),1,1)-WEEKDAY(DATE(TEXT(TODAY(),"yyyy"),1,1),2)+(WEEKNUM(TODAY())-1)*7+1),"DD"),", ",TEXT(MAX(DATE(TEXT(TODAY(),"yyyy"),1,1),DATE(TEXT(TODAY(),"yyyy"),1,1)-WEEKDAY(DATE(TEXT(TODAY(),"yyyy"),1,1),2)+(WEEKNUM(TODAY())-1)*7+1),"YYYY")," - ",TEXT(MIN(DATE(TEXT(TODAY(),"yyyy")+1,1,0),DATE(TEXT(TODAY(),"yyyy"),1,1)-WEEKDAY(DATE(TEXT(TODAY(),"yyyy"),1,1),2)+WEEKNUM(TODAY())*7),"MMMM")," ",TEXT(MIN(DATE(TEXT(TODAY(),"yyyy")+1,1,0),DATE(TEXT(TODAY(),"yyyy"),1,1)-WEEKDAY(DATE(TEXT(TODAY(),"yyyy"),1,1),2)+WEEKNUM(TODAY())*7),"DD"),", ",TEXT(MIN(DATE(TEXT(TODAY(),"yyyy")+1,1,0),DATE(TEXT(TODAY(),"yyyy"),1,1)-WEEKDAY(DATE(TEXT(TODAY(),"yyyy"),1,1),2)+WEEKNUM(TODAY())*7),"YYYY"))
This comment was minimized by the moderator on the site
Date(2017;1;7 * weeknumer - 5) 5 monday, 4 tuesday... :)
This comment was minimized by the moderator on the site
Or to make in not specific to the year 2017...
=DATE(YEAR,1,7 * WEEKNUM - WEEKDAY(DATE(YEAR,1,7) - 2))

2 monday, 3 tuesday,...
This comment was minimized by the moderator on the site
I'm sorry folks, but I could neither understand nor make work any of the formulas above so I finally figured out the following solution: DATE(B1,1,1)+($A4×7)−(6−(7−WEEKDAY(DATE(B1,1,1),first-day))) The first part "DATE(B1,1,1)+(B2×7)" simply takes January 1 of the year and adds the number of weeks. The next part calculates how many days to subtract from the WEEKDAY of January 1 to get the first day of the week. This is what I finally figured out: 6−(7−WEEKDAY(DATE(B1,1,1),first-day)) If, for example, January 1 falls on a Sunday (day 7), then this formula become "6-(7-7)" or simply 6 - which is the number of days you need to subtract to get Monday of that week. Try other days. Finally, if you want to find any other day of the week, just add the WEEKDAY number minus 1 to this result. So the last day of the week (Sunday) is: DATE(B1,1,1)+($A4×7)−(6−(7−WEEKDAY(DATE(B1,1,1),first-day)))+(7−1) Which can be simplified to: DATE(B1,1,1)+($A4×7)−(12−(7−WEEKDAY(DATE(B1,1,1),first-day))) Wednesday would be: DATE(B1,1,1)+($A4×7)−(8−(7−WEEKDAY(DATE(B1,1,1),first-day))) etc. I hope this helps someone else who needs this both with a workable solution along with a bit of understanding of how it was arrived at!
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