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
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','')"
}
}