メインコンテンツへスキップ

ExcelでXNUMXつの日付の間の週末/平日の数を数える方法は?

場合によっては、1つの日付の間の特定の平日がいくつあるかを知る必要があります。 たとえば、開始日が1年2014月2日、終了日が15年2014月XNUMX日のXNUMXつの日付があります。ここで、この期間に日曜日、月曜日、火曜日などが何回発生するかを知りたいと思います。 これは私たちにとってやや難しいかもしれませんが、ここでは、いくつかの効果的な方法について説明します。


式を使用して、XNUMXつの日付の間の特定の平日/週末の数を数えます

仮に、次のXNUMXつの日付があり、それらの間の日曜日の数を数える必要があります。 空白のセルを選択し、以下の数式を入力して、 入力します キー。 そして今、あなたはXNUMXつの日付の間の日曜日の数を取得します。 スクリーンショットを参照してください:

=INT((WEEKDAY($C$2- 1)-$C$2+$C3)/7)

注意:

(1)上記の式で、C2は開始日、C3は終了日を示します。

(2)上記の式では、 1 日曜日の略です。 また、番号1を1から7までの他の番号に置き換えることができます。(1は日曜日、2は月曜日、3は火曜日、4は水曜日、5は木曜日、6は金曜日、7は土曜日です。)


数式を使用して、月の特定の平日の数を数えます

2020年XNUMX月の水曜日の総数を数えると言うと、特定の月の特定の平日の総数を数える必要がある場合があります。ここでは、指定された特定の平日の総数を数える式を紹介します簡単に月。

空白のセルを選択し、数式の下に入力して、Enterキーを押してカウント結果を取得します。

=INT((WEEKDAY(DATE(G2,G3,1)- G4)-DATE(G2,G3,1)+EOMONTH(DATE(G2,G3,1),0))/7)

ノート:

(1)上記の式で、G2は指定された年、G3は指定された月、G4は指定された曜日です。

(2)この式は、曜日を表す整数を割り当てます。1は日曜日、2は月曜日、3は火曜日、4は水曜日、5は木曜日、6は金曜日、7は土曜日です。


ユーザー定義関数を使用して、特定の月の特定の平日/週末の数をカウントします

上記の式に加えて、特定の年と月の特定の平日数を計算するユーザー定義関数を作成することもできます。

1。 を押し続けます Alt + F11 キー、そしてそれは開きます Microsoft Visual Basic forApplicationsウィンドウ.

2に設定します。 OK をクリックします。 インセット > モジュール、次のコードをに貼り付けます モジュールウィンドウ.

Public Function TotalDays(pYear As Integer, pMonth As Integer, pDay As Integer)
'Update 20140210
Dim xindex As Integer
Dim endDate As Integer
endDate = Day(DateSerial(pYear, pMonth + 1, 0))
For xindex = 1 To endDate
    If Weekday(DateSerial(pYear, pMonth, xindex)) = pDay Then
        TotalDays = TotalDays + 1
    End If
Next
End Function

3。 このコードを保存してワークシートに戻り、空白のセルにこの数式を入力します = TotalDays(年、月、1) 。 この例では、2020年XNUMX月の日曜日の数を数えるので、この式を次の式のXNUMXつとして適用できます。、次にプレス 入力します キーを押すと、一度にいくつの日曜日を取得できます。 スクリーンショットを参照してください:

= TotalDays(C2、C3、C4)

= TotalDays(2020,6,1)

 

注意: この数式では、整数を使用して曜日を表します。 1は日曜日、2は月曜日、3は火曜日、4は水曜日、5は木曜日、6は金曜日、7は土曜日です。.


Kutools for Excelを使用して、XNUMXつの日付の間のすべての週末/平日/特定の曜日の数をカウントします

実際、Excel用のKutoolsを適用できます XNUMXつの日付の間の非稼働日数 式、 XNUMXつの日付の間の稼働日数 式、および 特定の平日の数を数える Excelの日付範囲内のすべての週末、週末、または特定の曜日の数をすばやくカウントする数式。

Kutools for Excel - Excel に必要な 300 以上のツールが詰め込まれています。 クレジット カードは必要なく、全機能を備えた 30 日間の無料トライアルをお楽しみください。 ダウンロード中!

1.カウント結果を配置する空白のセルを選択し、[Kutools]> [Formula Helper]> [Formula Helper]をクリックして、この機能を有効にします。

そして、あなたのカウントタイプに基づいて先に進んでください。

A. ExcelでXNUMXつの日付の間の週末(土曜日と日曜日)の数を数えます

Formulas Helperダイアログで、次のようにしてください。
(1)選択 統計的 数式タイプ ドロップダウンリスト;
(2)クリックして選択 XNUMXつの日付の間の非稼働日数 セクションに 式を選択してください リストボックス;
(3)開始日を 開始日 ボックス(日付セルを参照することもできます);
(4)終了日を 終了日 ボックス(日付セルを参照することもできます);
(5)をクリックします OK

これで、選択したセルのすべての土曜日と日曜日の総数が返されます。

Kutools for Excel - 300 以上の必須ツールで Excel を強化します。 クレジット カードは必要なく、全機能を備えた 30 日間の無料トライアルをお楽しみください。 今すぐ入手

B. ExcelでXNUMXつの日付の間の平日(土曜日と日曜日を除く)の数を数えます

Formulas Helperダイアログで、次のようにしてください。
(1)選択 統計的 数式タイプ ドロップダウンリスト;
(2)クリックして選択 XNUMXつの日付の間の稼働日数 セクションに 式を選択してください リストボックス;
(3)開始日を 開始日 ボックス(日付セルを参照することもできます);
(4)終了日を 終了日 ボックス(日付セルを参照することもできます);
(5)をクリックします OK

次に、選択したセルの平日(土曜日と日曜日を除く)の総数を返します。

Kutools for Excel - 300 以上の必須ツールで Excel を強化します。 クレジット カードは必要なく、全機能を備えた 30 日間の無料トライアルをお楽しみください。 今すぐ入手

C. ExcelでXNUMXつの日付の間の特定の曜日(月曜日、土曜日、日曜日など)の数を数えます

Formulas Helperダイアログで、次のようにしてください。
(1)選択 統計的 数式タイプ ドロップダウンリスト;
(2)クリックして選択 特定の平日の数を数える セクションに 式を選択してください リストボックス;
(3)開始日を 開始日 ボックス(日付セルを参照することもできます);
(4)終了日を 終了日 ボックス(日付セルを参照することもできます);
(5)特定の平日を整数で指定します(1は日曜日、2-5は月曜日から金曜日、7は土曜日を示します)。
(6)をクリックします OK

次に、指定された日付範囲内の指定された平日の総数を返します。

Kutools for Excel - 300 以上の必須ツールで Excel を強化します。 クレジット カードは必要なく、全機能を備えた 30 日間の無料トライアルをお楽しみください。 今すぐ入手


関連記事:

最高のオフィス生産性向上ツール

🤖 Kutools AI アシスタント: 以下に基づいてデータ分析に革命をもたらします。 インテリジェントな実行   |  コードを生成  |  カスタム数式の作成  |  データを分析してグラフを生成する  |  Kutools関数を呼び出す...
人気の機能: 重複を検索、強調表示、または識別する   |  空白行を削除する   |  データを失わずに列またはセルを結合する   |   数式なしのラウンド ...
スーパールックアップ: 複数の基準の VLookup    複数の値の VLookup  |   複数のシートにわたる VLookup   |   ファジールックアップ ....
詳細ドロップダウン リスト: ドロップダウンリストを素早く作成する   |  依存関係のドロップダウン リスト   |  複数選択のドロップダウンリスト ....
列マネージャー: 特定の数の列を追加する  |  列の移動  |  Toggle 非表示列の表示ステータス  |  範囲と列の比較 ...
注目の機能: グリッドフォーカス   |  デザインビュー   |   ビッグフォーミュラバー    ワークブックとシートマネージャー   |  リソースライブラリ (自動テキスト)   |  日付ピッカー   |  ワークシートを組み合わせる   |  セルの暗号化/復号化    リストごとにメールを送信する   |  スーパーフィルター   |   特殊フィルター (太字/斜体/取り消し線をフィルター...) ...
上位 15 のツールセット12 テキスト ツール (テキストを追加, 文字を削除する、...)   |   50+ チャート 種類 (ガントチャート、...)   |   40+ 実用的 (誕生日に基づいて年齢を計算する、...)   |   19 挿入 ツール (QRコードを挿入, パスから画像を挿入、...)   |   12 変換 ツール (数字から言葉へ, 通貨の換算、...)   |   7 マージ&スプリット ツール (高度な結合行, 分割セル、...)   |   ... もっと

Kutools for Excel で Excel スキルを強化し、これまでにない効率を体験してください。 Kutools for Excelは、生産性を向上させ、時間を節約するための300以上の高度な機能を提供します。  最も必要な機能を入手するにはここをクリックしてください...

説明


Officeタブは、タブ付きのインターフェイスをOfficeにもたらし、作​​業をはるかに簡単にします

  • Word、Excel、PowerPointでタブ付きの編集と読み取りを有効にする、パブリッシャー、アクセス、Visioおよびプロジェクト。
  • 新しいウィンドウではなく、同じウィンドウの新しいタブで複数のドキュメントを開いて作成します。
  • 生産性を 50% 向上させ、毎日何百回もマウス クリックを減らすことができます!
Comments (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Let's say you want to calculate the 3rd Thursday of the month and assume the date of the first of the month is in cell A1. We need to first work out the date of the Thursday in the week of A1. Because Thursday is the 5th day of the week, we use: =A1-WEEKDAY(A1)+5 Then if this Thursday falls before A1, we need to add 7 using [b]((A1-WEEKDAY(A1)+5)
This comment was minimized by the moderator on the site
What about a formula that returns the actual date of the first Wed of each month, Or the 2nd and 3rd tuesday of each month? Or every 3rd tuesday? I want to be able to put in my own start and end dates and then get the actual DATES (not the count) returned to me. Any ideas?
This comment was minimized by the moderator on the site
hi sir, i want to calculate no. of weeks in excel between two dates, but Dose not see right weeks as per date for example: I enterd the date 01/01/2016 ( Friday) and second date 14/01/2016( thursday) no of weeks showing = 2 weeks. but i want to show exact 2 weeks completed 15/01/2016 other wise show previse no fo weeks.
This comment was minimized by the moderator on the site
Let the start and end dates be in cells A1 and A2, respectively. This should work: =INT((A2-A1)/7)
This comment was minimized by the moderator on the site
Is it possible to have the start date set to "=today()" and the end date, for example, the 22nd of the current cycle. As the date returns to the 23rd, refresh the formula to the following 22nd?
This comment was minimized by the moderator on the site
Assuming cycle refers to month, this should work for the end date: DATE(YEAR(TODAY()),MONTH(TODAY())+IF(DAY(TODAY())>22,1,0),22)
This comment was minimized by the moderator on the site
Why are my comments not published completely????
This comment was minimized by the moderator on the site
[quote]Why are my comments not published completely????By Mohamed[/quote] Sorry, please try to send me the formula to jaychivo#extendoffice.com. Please replace @ with #. And i will help you post it. May be there are some characters which have been blocked. :-)
This comment was minimized by the moderator on the site
Hi Jaco, You may achieve this for someone who works Mondays (2), Wednesdays (4) and Fridays (6) as follows: (1) Call the year's start and end dates [quote]StartDate[/quote] and [quote]EndDate[/quote], respectively. (2) List all the public holidays in South Africa (this could span more than one year) in a range and call it [quote]PublicHolidays[/quote] (3) To calculate the total number of days worked enter the following array formula: [quote]=INT((WEEKDAY(StartDate-2)-StartDate+EndDate )/7)+INT((WEEKDAY(StartDate-4)-StartDate+EndDate )/7)+INT((WEEKDAY(StartDate-6)-StartDate+EndDate )/7)-SUM(IF((PublicHolidays>=StartDate)*(PublicHolidays
This comment was minimized by the moderator on the site
Sorry the formula above is not complete: It should be: =INT((WEEKDAY(StartDate-2)-StartDate+EndDate)/7)+INT((WEEKDAY(StartDate-4)-StartDate+EndDate)/7)+INT((WEEKDAY(StartDate-6)-StartDate+EndDate)/7)-SUM(IF((PublicHolidays>=StartDate)*(PublicHolidays
This comment was minimized by the moderator on the site
I don't know what happened to my formula and the rest of my message above. The formula should be: =INT((WEEKDAY(StartDate-2)-StartDate+EndDate )/7)+INT((WEEKDAY(StartDate-4)-StartDate+EndDate)/7)+INT((WEEKDAY(StartDate-6)-StartDate+EndDate )/7)-SUM(IF((PublicHolidays>=StartDate)*(PublicHolidays
This comment was minimized by the moderator on the site
Hi, I am from South Africa and I need advice. I have two workers at work who works different days. Now I want to type in a formula in excel to count how many days a year she work (that I can do), but the trick comes in when I want to type in a formula which allows me to deduct if one of her working days is a public holiday for example she works Monday, Wednesday and Friday. That means she works 156 days per year, but I want excel to deduct the holidays if it is on one of her working days. Can someone please assist me?
This comment was minimized by the moderator on the site
Does not work properly. You need to consider what day you're starting from and ending with!
This comment was minimized by the moderator on the site
Hi Laura, Could you please elaborate?
This comment was minimized by the moderator on the site
Thank you for this. Question, how do I add another day like "Wednesday or 4" to the Monday? Basically I want it to calculate both the total of Mondays and Wednesdays between the two dates. How do I write this formula? Thanks again
This comment was minimized by the moderator on the site
To help future seekers. Use this formula for calculating days between two dates: =NETWORKDAYS.INTL( start_date, end_date, [weekend], [holidays] ) =NETWORKDAYS.INTL(A3,A4,"00000011",C3:C8) - 0=include day 1=exclude day
This comment was minimized by the moderator on the site
THANK YOU VERY MUCH!!! This is perfect! This function exactly does the task!
This comment was minimized by the moderator on the site
Try =INT((WEEKDAY($B$1-2)-$B$1+$B2)/7)+INT((WEEKDAY($B$1-4)-$B$1+$B2)/7)
This comment was minimized by the moderator on the site
Thank You. This is so useful.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations