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

Diwakar Kittur 21 Reputation points
2021-03-10T17:45:33.107+00:00

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.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,826 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Allen Xu_MSFT 13,831 Reputation points
    2021-03-11T01:50:01.02+00:00

    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:
    76495-image.png

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

     =TEXT([DateColumnName],”dd-mmm-yyyy”)  
    

    76541-image.png
    Test result in my environment:
    76551-1.png


    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
    2022-02-03T16:39:28.47+00:00

    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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.