web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

change date format on the field

(0) ShareShare
ReportReport
Posted on by 815

Hi,

I have created 2 fields. 1 set as "System Shipped Date" date only field  and another 1 as "Warranty Status" calculated field.

Date format is showing perfectly and the requirement is need to change the display format on the field.

Instead of showing as 4/10/2018 it should show as April 10 2018

Please note this requirement is only for that field not for the entire system.

PFA

7206.Untitled1.png

Regards

Faisal

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello Faisal,

    You can't change display format for one field. As alternative solution you can create "string" field and populate it with data format you would like to use through code.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Syed,

    Sorry , Out of the box  you can not change the date format for specific field in dynamics CRM

  • Syed_Faisal Profile Picture
    815 on at

    Hi,

    Can display the format using javascript code, as the field job just to Display the date ?

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Sayed,

    Create a single line text field and in onload get the data from original field and change the format using JS and set the value to new field. Hide the original field .

  • Syed_Faisal Profile Picture
    815 on at

    Hi Goutam,

    Could you help me with the code.

    function ChangeDateFormat(){

    Xrm.Page.getAttribute("new_warrantystatus").setValue(Date.now());

    }

    what could be setvalue ? Month Date Year

  • gdas Profile Picture
    50,091 Moderator on at

    ok let me check will update in a while.

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Here is code that you can use:

    var d = new Date();

    var monthes = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

    var result = monthes[d.getMonth()] + " " + d.getDate() + " " + d.getFullYear();

    Xrm.Page.getAttribute("your customer string field").setValue(result);

    Good luck.

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Sayed ,

    Here you go -

            function ChangeDateFormat() {
                var d = new Date();
                var month = new Array();
                month[0] = "January";
                month[1] = "February";
                month[2] = "March";
                month[3] = "April";
                month[4] = "May";
                month[5] = "June";
                month[6] = "July";
                month[7] = "August";
                month[8] = "September";
                month[9] = "October";
                month[10] = "November";
                month[11] = "December";
                var Month = month[d.getMonth()];
                var Day = d.getDate();
                var Year = d.getFullYear();
                var datewithFormat = Month + " " + Day + " " + Year;          
                Xrm.Page.getAttribute("new_warrantystatus").setValue(datewithFormat);
    
            }


  • Syed_Faisal Profile Picture
    815 on at

    Hi Goutham,

    Thanks for the code, it is working absolutely perfect. 

    4604.Untitled1.png

    Regards

    Faisal

  • Syed_Faisal Profile Picture
    815 on at

    Hi Goutham,

    Code is working fine but we need to change something on the code.

    Issue here is it is setting up today's date but we actually want the date which is already exist on the field only that format needs to change.

    What is happening is, when we run the code the existing OLD date is also getting change and set to today's date.

    Could you please help?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans