locked
Only display month in date field RRS feed

  • Question

  • Hey guys,

    Is there a way to get CRM to only display the Month or Month and Day without the Year? For example 10/31/2009 I just want 10/31 to be displayed, but not only in the field when I am in "Active Accounts" View as well. Thanks!

    Wednesday, December 1, 2010 3:54 PM

Answers

  • You can try to use following JavaScript at OnChange handler of DateTime field:

    var value = crmForm.all.<your datetime field>.DataValue;

    if (value != null)

    {

    crmForm.all.<your varchar field>.DataValue =  (value.getMonth() < 9 ? ('0' + (value.getMonth()+1)) : ('' + (value.getMonth() + 1))) + '/' +  (value.getDate() < 10 ? ('0' + value.getDate()) : ('' + value.getDate()));

    }

     

    I haven't tested it but it seems to be correct.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Wednesday, December 1, 2010 6:07 PM
    Moderator

All replies

  • Hello.

    The only way is to create custom varchar field and insert formatted with JavaScript value there by OnChange event.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Wednesday, December 1, 2010 4:23 PM
    Moderator
  • What would be the javascript to do that? Is there anywhere I can go to read on how to do this? Thanks!
    Wednesday, December 1, 2010 5:47 PM
  • You can try to use following JavaScript at OnChange handler of DateTime field:

    var value = crmForm.all.<your datetime field>.DataValue;

    if (value != null)

    {

    crmForm.all.<your varchar field>.DataValue =  (value.getMonth() < 9 ? ('0' + (value.getMonth()+1)) : ('' + (value.getMonth() + 1))) + '/' +  (value.getDate() < 10 ? ('0' + value.getDate()) : ('' + value.getDate()));

    }

     

    I haven't tested it but it seems to be correct.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Wednesday, December 1, 2010 6:07 PM
    Moderator
  • Perfect I'll try that thank you.
    Thursday, December 2, 2010 1:40 PM