SharePoint list date column validation

SR VSP 1,251 Reputation points
2021-09-26T01:13:04.867+00:00

Hello,

I've a SharePoint list with due date column field. I want to apply a condition like Ex: With in 10 days of the due date the item should show in "Red color" can you advise ? And also can we show as a bar kind of visual layout in a separate view if possible

PFA

135190-due-date.jpg

Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

Accepted answer
  1. Emily Du-MSFT 51,836 Reputation points Microsoft External Staff
    2021-09-27T03:08:15.16+00:00

    @SR VSP

    Based on your description, I understand that Due date is less than 10 days from today's date, then row background color displays in red. Here're steps:

    1.All Documents -> Format current view -> Advanced mode.
    135387-1.png
    2.Use below codes in the Advanced mode.

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

    135424-2.png
    3.Result.
    135409-3.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Brian Curtis 91 Reputation points
    2021-10-07T12:42:39.49+00:00

    I'm not sure the calculation part of this works correctly. I tried it on a list of mine, and it only colors past entries (Due Date has already passed), not any future ones. Even items with a Due Date of tomorrow (now -1) aren't being affected.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.