locked
How to convert MS CRM Soap Response's DateTime to JavaScript's Date RRS feed

  • Question

  • Hi,

    For last couple of hours I couldn't able to convert the value of DateTime of SOAP Response to JavaScript's Date format.

    Even, I have tried in Four ways, but not succeeded.

    Method 1:

                var strEnd = resultXml.selectSingleNode("//q1:gms_effectiveperiodfrom").nodeTypedValue;
                alert (strEnd );
                var dtEnd = Date.parse(strEnd);
                alert(dtEnd);

               crmForm.all.gms_oldperformanceperiodend.DataValue =  dtEnd;

    Method2:

                 var strEnd = resultXml.selectSingleNode("//q1:gms_effectiveperiodfrom").nodeTypedValue;
                 var dtEnd = new Date();

                 var yearEn = strEnd.substring(0,4);
                 var monthEn = strEnd.substring(5,7);
                 var dateEn = strEnd.substring(8,10);

                 dtEnd.setMonth(monthEn);
                 dtEnd.setDate(dateEn);
                 dtEnd.setYear(yearEn);
                 alert(dtEnd);
                 crmForm.all.gms_oldperformanceperiodend.DataValue = dtEnd;

    Method 3:

    crmForm.all.gms_oldperformanceperiodend.DataValue = resultXml.selectSingleNode("//q1:gms_effectiveperiodfrom").nodeTypedValue;

    Method 4:

                var strEnd = resultXml.selectSingleNode("//q1:gms_effectiveperiodfrom").nodeTypedValue;
                alert (strEnd );
               var dtEnd = new Date(strEnd);
               alert(dtEnd);

               crmForm.all.gms_oldperformanceperiodend.DataValue =  dtEnd;

     

    please save my time :)


    Thanks, - Israel Pradeep, - Software Engineer & PMP & B.I - Entrepreneur, - "If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"".

    Tuesday, June 7, 2011 7:28 PM

Answers

  • Here Below is the code to convert the SOAP Response's DataTime to JavaScripts (MS CRM)'s DateTime

      if (resultXml.selectSingleNode("//q1:gms_effectiveperiodto")!=null)
      {
              var source2 = resultXml.selectSingleNode("//q1:gms_effectiveperiodto").nodeTypedValue;

                 var firstpart = source2.split('T')[0];
                 var secondpart = source2.split('T')[1].split('+')[0];
                 var parts =  firstpart .split('-');
                 //var parts2 = secondpart.split(':')

                var modifiedon2 = new Date();

                modifiedon2.setYear(parts[0]);
                modifiedon2.setMonth(parts[1] - 1);
                modifiedon2.setDate(parts[2]);             
              
               crmForm.all.gms_oldperformanceperiodend.DataValue =   modifiedon2;
      }


    Thanks, - Israel Pradeep, - Software Engineer & PMP & B.I - Entrepreneur, - "If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"".
    Tuesday, June 7, 2011 9:53 PM

All replies

  • Here Below is the code to convert the SOAP Response's DataTime to JavaScripts (MS CRM)'s DateTime

      if (resultXml.selectSingleNode("//q1:gms_effectiveperiodto")!=null)
      {
              var source2 = resultXml.selectSingleNode("//q1:gms_effectiveperiodto").nodeTypedValue;

                 var firstpart = source2.split('T')[0];
                 var secondpart = source2.split('T')[1].split('+')[0];
                 var parts =  firstpart .split('-');
                 //var parts2 = secondpart.split(':')

                var modifiedon2 = new Date();

                modifiedon2.setYear(parts[0]);
                modifiedon2.setMonth(parts[1] - 1);
                modifiedon2.setDate(parts[2]);             
              
               crmForm.all.gms_oldperformanceperiodend.DataValue =   modifiedon2;
      }


    Thanks, - Israel Pradeep, - Software Engineer & PMP & B.I - Entrepreneur, - "If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"".
    Tuesday, June 7, 2011 9:53 PM
  • Thank you so much!!!!!!

     

    I fought with this for a long time, and I don't think I could have solved it so easily without your help. 

    Tuesday, July 5, 2011 2:29 PM