Display date in dd-MMM-yyyy format in Modern view

Diwakar Kittur 6 Reputation points

I need to display date in dd-MMM-yyyy (eg: 10-Jan-2020) format in sharepoint online Modern view. I have to use OOTB features, no javascript or SPfx. I can use column formatting or adjust locale settings.

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
7,141 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Allen Xu_MSFT 13,576 Reputation points

    Hi @Diwakar Kittur ,

    To display date in "dd-mmm-yyyy", please use the following JSON code to format your column.

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

    Remember to replace $DateFormatting with the date column name in your end. Test result in my environment:

    An another way to achieve this is to create a Calculated(caculation based on other columns) column and use the below formula:


    Test result in my environment:

    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.

  2. Ashesh Sharma 1 Reputation point

    Hi Diwakar here is the updated code, I just used this for mine- I added "-TBD-" when its blank

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

    Let me know if this helps