CRM 2011 Date control

Answered CRM 2011 Date control

  • Wednesday, May 16, 2012 8:46 AM
     
     

    Hi

     I have date control in CRM nd one Numeric field control.

    if date is 10/10/2012

     and Numberic field values is 10

     I want to add 10/10/2022 means i have to add the values to years..

    How can i do it


    Rammohan

All Replies

  • Wednesday, May 16, 2012 9:42 AM
    Moderator
     
     Proposed Has Code

    Try to use following code:

    var d = Xrm.Page.getAttribute("your date time field").getValue();
    var delta = Xrm.Page.getAttribute("your integer field").getValue();
    
    if (d != null && delta != null)
    {
    d.setFullYear(d.getFullYear() + delta);
    Xrm.Page.getAttribute("your date time field").setValue(d);
    }


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Follow Andriy on Twitter

  • Wednesday, May 23, 2012 4:02 AM
     
     

    Hi

    d.setFullYear(d.getFullYear() + delta);

    instead of SetFullYear   SetFullDays funtion is it work?

     I want to add the days please tell me the method..

    SetFullDays  is not working for me



    Rammohan

  • Wednesday, May 23, 2012 4:13 AM
     
     Proposed

    Rammohan,

    To set the day, you would need d.setDate(day);

    To set the month, you can call d.setMonth(month - 1); // Need to put -1 to get the correct month

    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.


    Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits


  • Wednesday, May 23, 2012 4:14 AM
    Moderator
     
     Answered

    Hi

    d.setFullYear(d.getFullYear() + delta);

    instead of SetFullYear   SetFullDays funtion is it work?

     I want to add the days please tell me the method..

    SetFullDays  is not working for me



    Rammohan

    Guessing is wrong approach. Have you tried search engines? I tried and I found an answer in 1 minute. Here is description of Date object in JavaScript - http://www.w3schools.com/jsref/jsref_obj_date.asp

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Follow Andriy on Twitter

  • Wednesday, May 23, 2012 4:22 AM
     
     Answered

    Andrii,

    Sorry typo there. I've updated the original post.

    Cheers.


    Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits