Conditional Formatting based on empty Date column

Copper Contributor

Good Morning

 

I have a SharePoint list and I want to apply conditional formatting if an item hasn't been submitted, in which case a Date field will be empty.

 

I have applied other formatting based on whether a column contains data by simply picking the column, 'is equal to' or 'is not equal to' and then leave the last field blank. But that doesn't seem to work with a Date field.

 

I've also tried to put the condition as 'Column' 'is not equal to' '1/1/1990' - in the hope that picking a date long ago, nothing will match but this doesn't work either.

 

I have other conditions so I didn't really want to go to JSON. I don't know enough to work out how to put 3 conditions together!

 

Is there any way to conditionally format based on the empty Date value?

 

Thanks,

Christine

10 Replies

@Amapola67 you can format the date column in advanced mode as follows:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "background-color": "=if(Number(@currentField) == 0, '#541417', 'green')",
    "color": "white"
  }
}

SP-List.png

 

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

@RobElliott Thanks!

But that only formats that field while I'm trying to format the entire item. As a work around, I've introduced a Status column but that means I need to manually update it .. :sad:

 

Amapola67_0-1635710224517.png

 

@Amapola67 If you want to format entire row based on empty date column, you have to use view formatting.

Example:

 

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "additionalRowClass": "=if([$StartDate], '', 'sp-field-severity--severeWarning')"
}

 

 

 

ganeshsanap_0-1635753998021.png

Similarly, you can apply any of the predefined classes instead of 'sp-field-severity--severeWarning' as given in below links as per your requirements:

  1. Predefined classes
  2. Reusable SharePoint Online Classes for Modern UI

See other ways to check if date column is empty at: SharePoint JSON formatting: Check if date & time column is blank/empty


Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

@ganeshsanap 

 

As I have multiple conditional formats, I need to put your code into what was generated. I made the read bit Date is not some date but it generates an awful lot of code compared to your string.  (I know from VBA that a well-structured code is easier to read but JSON seems to go a bit over the top! It's no longer well structured, it's blown up.)

 

And quite frankly, I can't make head or tail of the code.  There's no if that I can see. 

 

Can I incorporate your code string in this?

          {
            "operator": ":",
            "operands": [
              {
                "operator": "==",
                "operands": [
                  {
                    "operator": "Date()",
                    "operands": [
                      {
                        "operator": "toDateString()",
                        "operands": [
                          {
                            "operator": "Date()",
                            "operands": [
                              "[$EnteredPhoenix]"
                            ]
                          }
                        ]
                      }
                    ]
                  },
                  {
                    "operator": "Date()",
                    "operands": [
                      {
                        "operator": "toDateString()",
                        "operands": [
                          {
                            "operator": "Date()",
                            "operands": [
                              "Sun Jan 01 2012"
                            ]
                          }
                        ]
                      }
                    ]
                  }
                ]
              },
              "sp-css-backgroundColor-BgPeach sp-css-color-PeachFont",

 

@Amapola67 "But that only formats that field while I'm trying to format the entire item" - it would have been helpful if you'd said that in your original post!

 

Rob
Los Gallardos
Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

 

 

@RobElliott 

Sorry, must be my wording. I have been trying to avoid learning SharePoint .. I thought 'item' was an entry, i.e. the line. Vs. column which is a field?

 

So when I said I'm trying to format the item, I meant I'm trying to format the line. Trying to speak SharePoint and obviously failing. 

No need to apologise, I sounded irritated which I didn't mean to but one of our staff had done something incredibly stupid on one of our sites just before I posted.

Rob

@RobElliott Good staff is so hard to find these days :smile:

I'm learning more about SharePoint these days than I ever wanted to know!!

 

Have a good day!

Christine

@Amapola67,

I realize this is a bit dated now, but I believe this can still be done with the out-of-the-box conditional formatting style editor --for those interested in just formatting an individual date column, by simply choosing the "is between" comparison and leaving the date selections empty.

 

Kregg1122_0-1701366588129.png

 

 

 

@Kregg1122

 

Nice. I will have to try that. - Never too late to learn! :smile:

 

Thank you!