跳到主要內容

如何在Excel中根據日期進行條件格式設置?

眾所周知,條件格式可以根據單元格內容自動更改單元格格式。 在本教程中,我將介紹如何在Excel中根據日期條件格式化單元格。

條件格式日期等於/大於/早於TODAY

過去日期的條件格式

有條件地格式化將來的日期

兩個日期之間的條件格式

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


條件格式日期等於/大於/早於TODAY

要設置條件格式日期,您需要創建一個新規則。

1.選擇要添加條件格式的單元格,單擊 首頁 > 條件格式 > 新規則.
doc條件格式日期1

2。 在裡面 新格式規則 對話框中選擇 使用公式來確定要格式化的單元格 in 選擇規則類型 部分,然後根據需要選擇一個公式 格式化此公式為真的值 文本框。

  • 等於今天:=$B2=TODAY()
  • 比今天更好: =$B2>TODAY()
  • 比今天更舊: =$B2<TODAY()

doc條件格式日期2

3。 點擊 格式單元格格式 對話框中,選擇一種要突出顯示所需單元格的格式。
doc條件格式日期3

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

備註:今天是15/8/2018
doc條件格式日期4


過去日期的條件格式

如果要有條件地格式化過去的日期,可以在“新建格式規則”對話框中執行以下操作。

1.根據需要選擇以下公式之一,然後將其鍵入到 格式化此公式為真的值 文本框。

  • 30多天前: =TODAY()-$B2>30
  • 從30到15天(含)之前: =AND(TODAY()-$B2>=15, TODAY()-$B2<=30)
  • 不到15天前: =AND(TODAY()-$B2>=1, TODAY()-$B2<15)

2。 然後點擊 格式 在中選擇一種格式 單元格格式 對話。

3。 點擊 OK > OK 關閉對話框。

備註:今天是15/8/2018
doc條件格式日期5


有條件地格式化將來的日期

要有條件地格式化將來的日期,可以執行以下操作:

1.根據需要選擇以下公式之一,然後將其鍵入到 格式化此公式為真的值 文本框。

  • 從現在起30天內將發生: =$B2-TODAY()>30
  • 在30到15天內(包括XNUMX天): =AND($B2-TODAY()>=15, $B2-TODAY()<=30)
  • 在不到15天的時間內: =AND($B2-TODAY()>=1, $B2-TODAY()<15)

2。 然後點擊 格式 在中選擇一種格式 單元格格式 對話。

3。 點擊 OK > OK 關閉對話框。


兩個日期之間的條件格式

要在兩個日期之間進行條件格式設置,請選擇單元格並使用此公式, =AND($B2>=$D$2,$B2<=$E$2) D2是開始日期,E2是結束日期。 然後使用所需的格式格式化單元格。

doc條件格式日期6
doc條件格式日期7

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

如果要根據另一列中的日期對單元格進行條件格式設置,則可以執行這些操作。

1.假設您要突出顯示C列中的銷售額,而B列中的相對日期是16/8/2018,請首先選擇C列範圍。

2.啟用“新格式設置規則”對話框並鍵入此公式 =$B2=DATEVALUE("8/16/2018") 格式化此公式為真的值 文本框,然後將單元格格式設置為 單元格格式 對話。

doc條件格式日期8
doc條件格式日期9

注意: 在上述公式中,B2是所選日期範圍的第一個日期單元格。


最佳辦公生產力工具

🤖 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 (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How can I automatically add a date when a cell contains certain text? So, for example, if cell A1 contains "to do", a date is automatically added in another cell. This date is based on a date also from a cell and I would like to add a date + 65 days in the future. Is this possible?
This comment was minimized by the moderator on the site
Cześć, mierzę się z problemem warunkowego podświetlania daty, np.: w kolumnie A mam datę startu danej czynności np. 01.01.2023, w kolumnie B mam datę końca danej czynności np. 07.01.2023 i chodziłoby mi o to, żeby wyróżnić warunkowo np. kolorem zielonym datę w kolumnie B jeżeli pomiędzy datą startu, a datą końca czynności upłynęło mniej niż 7 dni, jeżeli 7 dni i więcej kolorem czerwonym.
This comment was minimized by the moderator on the site
Use two formulas in the conditional formatting dialog:
difference between start date and end date is greater than or equal to 7 days: =B2-A2>=7 format to red
difference between start date and end date is smaller than 7 days: =B2-A2<7 format to green
see screenshot:
https://cdn.extendoffice.com/images/stories/comments/sun-comment/doc-difference-greater-than-7.png
This comment was minimized by the moderator on the site
Cześć, mierzę się z problemem warunkowego podświetlania daty, np.: w kolumnie A mam datę startu danej czynności np. 01.01.2023, w kolumnie B mam datę końca danej czynności np. 07.01.2023 i chodziłoby mi o to, żeby wyróżnić warunkowo np. kolorem zielonym datę w kolumnie B jeżeli pomiędzy datą startu, a datą końca czynności upłynęło mniej niż 7 dni, jeżeli 7 dni i więcej kolorem czerwonym.
This comment was minimized by the moderator on the site
Cześć, mierzę się z problemem warunkowego podświetlania daty, np.: w kolumnie A mam datę startu danej czynności np. 01.01.2023, w kolumnie B mam datę końca danej czynności np. 07.01.2023 i chodziłoby mi o to, żeby wyróżnić warunkowo np. kolorem zielonym datę w kolumnie B jeżeli pomiędzy datą startu, a datą końca czynności upłynęło mniej niż 7 dni, jeżeli 7 dni i więcej kolorem czerwonym.
This comment was minimized by the moderator on the site
Ciao, come posso utilizzare il conditional formatting per evidenziare il mese corrente e il mese successivo?
This comment was minimized by the moderator on the site
Hi, Michela,
highlight the date in current month, please use formula =TEXT(TODAY(),"m")-TEXT(A1,"m")=0 in conditional formatting new rule dialog, and select a color such as yellow to outstanding the dates.
highlight the date in next month, use formula =TEXT(A1,"m")-TEXT(TODAY(),"m")=1 in conditional formatting new rule dialog, and select a color such as green to outstanding the dates.
see screenshot:
https://cdn.extendoffice.com/images/stories/comments/sun-comment/doc-highlight-current-month.png
This comment was minimized by the moderator on the site
Hello there! I have been searching everywhere for an answer to my problem. I really hope that you can help. I have a column of dates that have taken place in the past. It was when a medical fit test was performed. Those need to be done every two years. What I would like to do is have the dates highlight the box Yellow when they are within being 30 days due, and then Red as soon as they are past due. (So if the date in the box is 1/1/2021, it would turn yellow on 12/1/22. It would then turn red on 1/2/23) These dates are a column in a database so I can't just put a date in a cell to be the reference in the formula. I can only use the cell with the date itself. My brain has melted trying to figure this out, please help. I've gone in Excel formula circles and keep coming up with nothing.

I also have a second column that I need to do the same thing with where it happens on a yearly basis.

Any help will be appreciated. Thank you
This comment was minimized by the moderator on the site
Hi, Kris, create two rules in the conditional formatting dialog:
=AND(0<DATE(YEAR($A1)+2,MONTH($A1),DAY($A1))-TODAY(),DATE(YEAR($A1)+2,MONTH($A1),DAY($A1))-TODAY()<=30) using this formula and choose yellow filled color to mark the within 30 days due
=(DATE(YEAR(A1)+2,MONTH(A1),DAY(A1))<TODAY()) using this formula and choose red filled color to mark the past due
This comment was minimized by the moderator on the site
Hola!

como puedo hacer una formula para que si columna D es igual a la comuna E sea verdadero, pero si columna A + 90 dias es igual al columna E siga siendo verdadero de lo contrario sea falso, gracias.
This comment was minimized by the moderator on the site
Hi, try this formula:=IFERROR(IFS(E2=D2,"TRUE",E2=A2+90,"TRUE"),"""FALSE")
Notice that if you are not in other lagnuage version, maybe you need to transform the formula to your local language.
This comment was minimized by the moderator on the site
ERP PO No. Region Update-1 Supplier PIC Note To Receiver PO Age
1091BPA6438143-121 Bali - Lombok Not Yet Implement PS2MS XL 31
1091BPA6438143-123 Bali - Lombok Not Yet Implement Lumpsum 31
1091BPA6438143-124 Bali - Lombok Not Yet Implement Service Package 31
1091BPA6438143-125 Bali - Lombok Not Yet Implement Battery Maintenance 31
1091BPA6438143-127 Bali - Lombok Not Yet Implement MS Dismantle Board 22

kalau cara conditional formating untuk PO aging Lebih dari 70 gimana ya, tapi di file pivot, karena database saya untuk po aging 70 itu pake rumus =IFERROR(DATEDIF(NOW();B56;"d");""&DATEDIF(B56;NOW();"d")) jadi saat saya conditional formating aging lebih dari 70 dengan warna merah itu tidak ke detack di pivotnya,
mohon bantuannya😁
This comment was minimized by the moderator on the site
Bonjour,
je cherche dans GOOGLE SHEET à faire une mise en forme conditionnelle par rapport à une date; je cherche à faire en sorte que quand la date inscrite dans une case dépasse 15jrs alors elle devienne rouge. (01/08/22 dans la case, quand nous sommes le 16/08/22 je voudrais que la case devienne rouge)

merci d'avance.
This comment was minimized by the moderator on the site
Hi, vex, sorry that I only can reply with English since I do not know French. Supposing you want to format all dates that over 15 days based on a date 7/21/2022, you may firstly, change the date 7/21/2022 to a number, 44763, then select the dates that you want to highlight, click Format > Conditional Formatting, and choose Custom formula is in the Format Rules section, type B2>44763+15, and choose red color. See the screenshot:
https://www.extendoffice.com/images/stories/comments/sun-comment/doc_google_sheet_conditional_formatting.png
Hope can help you.
This comment was minimized by the moderator on the site
Bonjour, j'ai téléchargé un document excel pour la gestion des congés: Shift staff. Je voudrais que certaines dates soient conditionnées pour rester inactives chaque année (il s'agit des congés légaux comme le 1er janvier ou le 15 aout) - actuellement je ne peux conditonner que les jours de la semaine, pas les dates - pouvez-vous m'aider?

Merci beaucoup

Pascale
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