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 from – https://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 Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

Leave a Reply

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