0

In SharePoint lists, I would like a date to show as "Fri, Jan 17, 2025", rather than just "Jan 17, 2025". Do you know how to do that? Could you also mark the weekend as red? Could you give me the JSON code? Thank you!

1 Answer 1

0

Using substring(), toDateString(), and indexOf() functions, we can accomplish this. For more details of these function, see Formatting Syntax Reference

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=substring(toDateString(@currentField), 0,3) + ', ' + substring(toDateString(@currentField), 4,10) + ', ' + substring(toDateString(@currentField), 11,15)",  
  "style": {
    "color": "=if((indexOf(toDateString(@currentField),'Sat')>-1 ||indexOf(toDateString(@currentField),'Sun')>-1), 'red','')"    
  }
}

enter image description here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.