跳到主要內容

如何在Excel中查找每個月的第一個或最後一個星期五?

通常星期五是一個月中的最後一個工作日。 如何在Excel中根據給定的日期找到第一個或最後一個星期五? 在本文中,我們將指導您如何使用兩個公式來查找每月的第一個或最後一個星期五。

查找一個月的第一個星期五
查找一個月的最後一個星期五


查找一個月的第一個星期五

例如,在給定的日期1/1/2015中位於單元格A2中,如下所示。 如果要根據給定日期查找每月的第一個星期五,請執行以下操作。

1.選擇一個單元格以顯示結果。 在這裡,我們選擇單元格C2。

2.複製以下公式並將其粘貼到其中,然後按 Enter 鍵。

=CEILING(EOMONTH(A2,-1)-5,7)+6

然後,日期顯示在單元格C2中,這意味著2015年1月的第一個星期五是日期2/2015/XNUMX。

筆記:

1.如果要查找其他月份的第一個星期五,請在A2單元格中輸入該月的指定日期,然後使用公式。

2.在公式中,A2是給定日期所在的參考單元格。 您可以更改它以滿足您的需求。

查找一個月的最後一個星期五

給定的日期1/1/2015位於單元格A2中,要在Excel中查找本月的最後一個星期五,請執行以下操作。

1.選擇一個單元格,將以下公式複製到其中,然後按 Enter 獲得結果的關鍵。

=DATE(YEAR(A2),MONTH(A2)+1,0)+MOD(-WEEKDAY(DATE(YEAR(A2),MONTH(A2)+1,0),2)-2,-7)

然後,2015年2月的最後一個星期五將顯示單元格BXNUMX。

備註:您可以將公式中的A2更改為給定日期的參考單元格。


相關文章:

最佳辦公生產力工具

🤖 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 (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Even shorter 😅
=lambda(Date;WeekDay;EOMONTH(Date;0)-WEEKDAY(EOMONTH(Date;0);WeekDay+10)+1
Where "WeekDay" parameter is 1=Monday, 7=Sunday
This comment was minimized by the moderator on the site
=lambda(Date;WeekDay;EOMONTH(Date;0)-WEEKDAY(EOMONTH(Date;0);WeekDay+10)+1)

I forgot a bracket at the end
This comment was minimized by the moderator on the site
Vậy công thức tính thứ sáu tuần thứ 2 của tháng như thế nào vậy ban?
This comment was minimized by the moderator on the site
Hi Tâm Cao Điền,
Suppose you want to calculate the second friday of the month based on the given date in A1, you can try the following formula:
=A18-DAY(A18)+CHOOSE(WEEKDAY(A18-DAY(A18),2),11,10,9,8,14,13,12)
This comment was minimized by the moderator on the site
porque cuando lo pruebo tal cual me sale error ?
o sea estoy copiando y pegando y no funciona

alguien sabe?
This comment was minimized by the moderator on the site
Hi andre,
Can you tell me which formula you used in the post? And what error your are experiencing?
This comment was minimized by the moderator on the site
Why not make the "last Friday" formula: =CEILING(EOMONTH(A2,0)-5,7)-1? That works for all dates I have tried....
This comment was minimized by the moderator on the site
Hi Eric,
Thanks for sharing it.
This comment was minimized by the moderator on the site
Hello and thank you for this formula. I am not an Excel guru and acnnot easily work out how to change this formula for the last Friday to be the Last Monday, or any other day. Can you please explain how to interpret this.
This comment was minimized by the moderator on the site
Matt,

The way the formula works is: First we find the last day of the month with the EOMONTH() function. For the last day of the current month, we use "0" as the month offset. For the previous month, it would be -1. (Either "=EOMONTH(A2,0)" or "=EOMONTH(A2,-1)".)

Then, in the "=CEILING()" function, we subtract the number of days required to bring us back to Sunday from the day for which we are searching. (For Tuesday, it would be -2, so we make the formula so far: "=CEILING(EOMONTH(A2,0)-2...."

We use the "significance" value of "7" because weeks are seven days long (of course).This finds the date of either the previous Saturday, or the following Saturday (Excel dates started with 1/1/1900, which was a Sunday. So if you enter a "1" in cell A2 with the Long Date format, the cell would read: "Sunday, January 1, 1900".). For that reason, the =CEILING() function, using "7" as the "significance" argument returns Saturday, which is always a multiple of 7 in Excel. Now the formula is "=CEILING(EOMONTH(A2,0)-2,7...".

Now we need to return the date to a Tuesday, so we either subtract 4 for the last Tuesday of the month, or add 3 for the first Tuesday of the next month. So the final formula is, respectively, either "=CEILING(EOMONTH(A2,0)-2,7)-4" or "=CEILING(EOMONTH(A2,0)-2,7)+3".

We can work through the math by assuming the last day of the month is either a Monday (assume its value is 9 - for ease of illustration, so the values do not go negative) or a Wednesday (assume value 11). "EOMONTH()" will return either of those days (9 or 11). Subtracting 2 results in the previous Saturday (value 7) or Monday (value 9), respectively. The CEILING() function then returns, respectively, the previous Saturday (value 7, because the ceiling of 7 with significance 7 is 7) or the current Saturday (value 14, because the ceiling of 9, significance 7, is 14). Subtracting 4 results in the previous Tuesday (value 3) or the current week's Tuesday (value 10), respectively. For the first Tuesday of the following month, adding 3 to the Saturday value (7 or 14) returns either Tuesday value 10, or Tuesday value 17, respectively.


Hopefully that helps you understand so that you can modify the formula as necessary. You can even change it to find the second Tuesday, or second to last Tuesday, by adding or subtracting an additional 7, respectively.
This comment was minimized by the moderator on the site
Hi Matt,
You just need to change the last number -7 to -1 to solove the problem.
=DATE(YEAR(A2),MONTH(A2)+1,0)+MOD(-WEEKDAY(DATE(YEAR(A2),MONTH(A2)+1,0),2)-2,-1)
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations