跳到主要内容

如何在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 Tab 为 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