Microsoft 365 : SharePoint Online – Date Column formatting – changing the display of date in datetime list column

Figure 2 : SharePoint online - Site Locale - Site Settings >> Regional Settings
Figure 2 : SharePoint online - Site Locale - Site Settings >> Regional Settings

Hi All,

Greetings for the day!!!

Today new learning 🙂

Details / Use Case

  • One of our user has SharePoint Online site and list
  • List having multiple date columns
  • Our respective user wants to change the display of date column and hence this article
  • Here, for demo purpose I am creating demo list as

Figure 1 : SharePoint Online - Modern List - DateFormat column - displaying date as per Locale
Figure 1 : SharePoint Online – Modern List – DateFormat column – displaying date as per Locale

Figure 2 : SharePoint online - Site Locale - Site Settings >> Regional Settings
Figure 2 : SharePoint online – Site Locale – Site Settings >> Regional Settings

Our user requirement

  • Our user want to show date format in “dd – month name – year” as “24 – Jan – 2023”
  • To fulfil this requirement we are using “Column Formatting” option
  • To change the “Column Formatting” we need to edit the column
  • To edit column – we need to go to List Settings and click on column as
Figure 3 : SharePoint Online - List - List Settings
Figure 3 : SharePoint Online – List – List Settings
Figure 4 : SharePoint Online - List - List Settings - Editing field – DateFormat
Figure 4 : SharePoint Online – List – List Settings – Editing field – DateFormat

Updating Column Formatting

  • Column formatting is used to change display of the column
  • We use JSON to update the formatting of column
  • Here, we need to change the display of column – DateFormat
  • Following is the JSON used to update the display of DateFormat column

{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "div",
   "txtContent": "=getDate([$DateFormat])+ '-' + if(getMonth([$DateFormat])==0,'Jan',if(getMonth([$DateFormat])==1,'Feb', if(getMonth([$DateFormat])==2,'Mar',if(getMonth([$DateFormat])==3,'Apr',if(getMonth([$DateFormat])==4,'May',if(getMonth([$DateFormat])==5,'June',if(getMonth([$DateFormat])==6,'July',if(getMonth([$DateFormat])==7,'Aug',if(getMonth([$DateFormat])==8,'Sept',if(getMonth([$DateFormat])==9,'Oct',if(getMonth([$DateFormat])==10,'Nov','Dec'))))))))))) + '-' + getYear([$DateFormat])"
}

Note : The above sample JSON is for only reference. If we copy-paste from here, it may not work. I would copy fromhttps://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting

SharePoint Online - List column formatting - formatting Date type column
Figure 5 : SharePoint Online – List column formatting – formatting Date type column

Once we update formatting our display of DateFormat column changes as

Figure 6 : SharePoint Online - List column formatting - formatting Date type column
Figure 6 : SharePoint Online – List column formatting – formatting Date type column

Thanks for reading! HAVE A FANTASTIC TIME AHEAD 😊

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: