Excel 按日期做條件格式(逾期、即將到期和週末)
將公式規則應用到日期列,並按區域的第一個單元格來寫。相對截止日期 F1,逾期可用 =A2<$F$1。週末在 WEEKDAY 返回型別 2(星期一為 1,星期日為 7)下,星期六為 6、星期日為 7,可用 =OR(WEEKDAY(A2,2)=6,WEEKDAY(A2,2)=7)。單元格必須是真正的日期,而不是看起來像日期的文本。
本文目錄
快速解答
將公式規則應用到日期列,並按區域的第一個單元格來寫。相對截止日期 F1,逾期可用 =A2<$F$1。週末在 WEEKDAY 返回型別 2(星期一為 1,星期日為 7)下,星期六為 6、星期日為 7,可用 =OR(WEEKDAY(A2,2)=6,WEEKDAY(A2,2)=7)。單元格必須是真正的日期,而不是看起來像日期的文本。
=A2<DATE(2024,3,1)檢查重點
2026 年 11 月 12 日測試中,DATE(2024,2,20)<DATE(2024,3,1) 為 TRUE,對 3 月 1 日和 3 月 4 日為 FALSE。WEEKDAY(DATE(2024,3,4),2) 為 1(星期一),WEEKDAY(DATE(2024,3,9),2) 為 6(星期六)。即將到期的七天視窗可用 =AND(A2>=$F$1,A2<=$F$1+7)。
邊界與相容性
若 ISNUMBER(A2) 為 FALSE,單元格是文本日期,比較可能不會按預期著色,應先轉換。規則寫成 =A1<$F$1 而區域從 A2 開始,會瞄高一行。TODAY() 每天都會變化,測試檔案裡更宜用 DATE 或單元格。可先在輔助列填寫同一公式,核對 TRUE 或 FALSE 再依賴顏色。
完整英文範例、公式與作者備註
Excel How-toTested in: The date comparisons and
WEEKDAYresults below were evaluated in Google Sheets on 12 November 2026. Excel 365 menu names are the current desktop labels; I did not click through Conditional Formatting in Excel this session.
The general feature guide is in Conditional Formatting in Excel. If a formula rule highlights the wrong rows, see formula not working. This page is only about date rules.
Overdue against a cutoff
Pick a cutoff you can test. In the test workbook the cutoff was 1 March 2024:
=A2<DATE(2024,3,1)
or, with the cutoff in F1:
=A2<$F$1
On 12 November 2026, =DATE(2024,2,20)<DATE(2024,3,1) was TRUE, and the same comparison for 1 March and for 4 March was FALSE. A due date that equals the cutoff is not overdue under a strict < rule; use <= if the due date itself should count.
Apply the rule to A2:A100 (or however long the list is), not to A1 if A1 is a header. To color the entire row, apply it to A2:F100 and lock the date column: =$A2<$F$1.
TODAY() is fine when you want the cutoff to move: =A2<TODAY(). I did not evaluate TODAY() in the test workbook on a frozen date, because it would change tomorrow. For a screenshot or a test file, prefer DATE or a cell.
Upcoming dates, and weekends
A window from the cutoff through the next seven days:
=AND(A2>=$F$1,A2<=$F$1+7)
If F1 is 1 March 2024, 4 March is inside that window and 20 February is not.
For weekends, use WEEKDAY with return type 2 so Monday is 1 and Sunday is 7:
=OR(WEEKDAY(A2,2)=6,WEEKDAY(A2,2)=7)
In the test workbook, =WEEKDAY(DATE(2024,3,4),2) returned 1 (4 March 2024 was a Monday) and =WEEKDAY(DATE(2024,3,9),2) returned 6 (a Saturday). Type 1 of WEEKDAY is different (Sunday = 1); do not mix the two types in the same rule.
Google Sheets uses the same formulas in Format > Conditional formatting > Custom formula is.
When the rule does nothing
If =ISNUMBER(A2) is FALSE, the cell is text that looks like a date, and a comparison against DATE or TODAY() will not highlight it reliably. Convert the column first, as in dates stored as text.
A rule written as =A1<$F$1 on a range that starts at A2 is aimed one row too high. A cutoff typed as 2024-03-01 but stored as text is the same class of problem as text dates in the list.
Built-in rules such as A Date Occurring > Yesterday can work for quick filters, but a formula you can test in a helper column is easier to check. Put =A2<$F$1 next to the first date, fill down, and confirm the TRUE/FALSE pattern before you rely on the color.