Skip to main content

如何根據 Excel 中的日期應用條件格式?

Author: Sun Last Modified: 2025-08-06

眾所周知,條件格式可以根據儲存格內容自動改變儲存格格式。在本教程中,我將介紹如何在 Excel 中根據日期對儲存格應用條件格式。

等於/大於/早於今天的日期的條件格式

過去日期的條件格式

未來日期的條件格式

兩個特定日期之間的日期條件格式

基於另一列中的日期的條件格式


等於/大於/早於今天的日期的條件格式

要為日期應用條件格式,您需要創建一個新規則。

1. 選擇要添加條件格式的儲存格,點擊 [Home] > [Conditional Formatting] > [New Rule]
A screenshot of the Conditional Formatting > New Rule menu in Excel

2. 在 [ New Formatting Rule] 對話框中,在 [Select a Rule Type] 區域選擇 [ Use a formula to determine which cells to format],然後根據需要在 [ Format values where this formula is true] 文本框中輸入公式。

  • 等於今天:=$B2=TODAY()
  • 大於今天:=$B2>TODAY()
  • 早於今天:=$B2

A screenshot of the New Formatting Rule dialog in Excel with the Use a formula to determine which cells to format option selected

3. 點擊 [Format] 進入 [Format Cells] 對話框,選擇一種格式以突出顯示所需的儲存格。
A screenshot of the Format Cells dialog in Excel

4. 點擊 [OK] > [OK]。日期已格式化。

備註:今天的日期是 2018 年 8 月 15 日。
A screenshot of the formatted cells based on the conditional formatting rules in Excel


過去日期的條件格式

如果您想為過去的日期應用條件格式,可以在 [New Formatting Rule] 對話框中按以下步驟操作。

1. 根據需要選擇以下公式之一,並將其輸入到 [Format values where this formula is true] 文本框中。

  • 超過 30 天前: =TODAY()-$B2>30
  • 從 30 到 15 天前(含):=AND(TODAY()-$B2>=15, TODAY()-$B2<=30)
  • 少於 15 天前:=AND(TODAY()-$B2>=1, TODAY()-$B2<15)

2. 然後點擊 [Format] [Format Cells] 對話框中選擇一種格式。

3. 點擊 [OK] > [OK] 關閉對話框。

備註:今天的日期是 2018 年 8 月 15 日。
A screenshot of the formatted cells based on the conditional formatting rules in Excel


未來日期的條件格式

要為未來的日期應用條件格式,您可以按照以下步驟進行操作:

1. 根據需要選擇以下公式之一,並將其輸入到 [ Format values where this formula is true] 文本框中。

  • 從現在起超過 30 天內發生: =$B2-TODAY()>30
  • 在 30 到 15 天內(含): =AND($B2-TODAY()>=15, $B2-TODAY()<=30)
  • 在不到 15 天內:=AND($B2-TODAY()>=1, $B2-TODAY()<15)

2. 然後點擊 [Format][Format Cells] 對話框中選擇一種格式。

3. 點擊 [OK] > [OK] 關閉對話框。


兩個特定日期之間的日期條件格式

要為兩個特定日期之間的日期應用條件格式,選擇儲存格並使用此公式:=AND($B2>=$D$2,$B2<=$E$2) ,其中 D2 是開始日期,E2 是結束日期。然後用所需的格式設置儲存格格式。

A screenshot showing the conditional formatting applied to cells in Excel between two dates
A screenshot of cells formatted based on conditional formatting rules for dates in Excel

基於另一列中的日期的條件格式

如果要根據另一列中的日期對儲存格應用條件格式,可以按照以下步驟進行操作。

1. 假設您希望在 B 列中的相應日期為 2018 年 8 月 16 日時突出顯示 C 列中的銷售數據,請首先選擇 C 列的範圍。

2. 啟動 [New Formatting Rule] 對話框,並在 [ Format values where this formula is true] 文本框中輸入公式 =$B2=DATEVALUE("8/16/2018"),然後在 [Format Cells] 對話框中設置儲存格格式。

A screenshot of the Format Cells dialog in Excel for formatting based on the date in another column
A screenshot of the New Formatting Rule dialog in Excel, highlighting the cells where the date is 16/8/2018

備註:在上述公式中,B2 是所選日期範圍的第一個日期儲存格。


最佳 Office 辦公效率工具

🤖 Kutools AI Aide:徹底革新數據分析,基於智能執行|生成程式碼|創建自訂公式|分析數據並生成圖表|調用 Kutools Functions
熱門功能查找、選取項目的背景色或標記重複值 | 刪除空行 | 合併列或單元格且不丟失資料 | 四捨五入...
高級 LOOKUP多條件查找|多值查找|多表查找|模糊查找...
高級下拉列表快速創建下拉列表 | 關聯下拉列表 | 多選下拉列表 ...
列管理器添加指定數量的列 | 移動列 | 切換隱藏列的可見狀態 | 區域與列比較 ...
精選功能網格聚焦 | 設計檢視 | 增強編輯欄 | 工作簿及工作表管理器 | 資源庫 (自動文本) | 日期提取器 | 合併資料 | 加密/解密儲存格 | 按清單發送電子郵件 | 超級篩選 | 特殊篩選(篩選粗體/傾斜/刪除線 ...)...
前15 大工具集12 款文本工具添加文本刪除特定字符,...)|50+ 種圖表 類型甘特圖,...)|40+ 實用 公式基於生日計算年齡,...)|19 款插入工具插入QR码按路徑插入圖片,...)|12 款轉換工具金額轉大寫匯率轉換,...)|7 款合併和分割工具高級合併行分割儲存格,...)| ...以及更多
使用 Kutools 支援你的語言——支援英語、西班牙語、德語、法語、中文及40 多種語言!

利用 Kutools for Excel 大幅提升你的 Excel 技能,感受前所未有的高效體驗。 Kutools for Excel 提供超過300 項高級功能,助你提升效率並保存時間。 點此查看你最需要的功能...


Office Tab 為 Office 帶來標籤式介面,讓你的工作更加輕鬆

  • 啟用 Word、Excel、PowerPoint 的標籤式編輯和閱讀功能
  • 在同一個視窗的標籤中打開和創建多個文件,而不是在新窗口中分開開啟。
  • 可提升你50% 的工作效率,每天為你大量減少滑鼠點擊次數!