Compare Datetime issue with dynamic CRM 2013 datetime data

廉价感情. 提交于 2019-12-08 10:42:52

问题


I am Unable to fetch date by compairing datetime with Dynamic CRM 2013. Below time format am using in my code even if i am using YYYY-MM-DD HH:MM format its fetching data based on date only not considering time . Can any have idea about this.

var SDate = new Date(document.getElementById("FromDate").value);
var EDate = new Date(document.getElementById("Todate").value);
var e = document.getElementById("FromTime");
var fromtime = e.options[e.selectedIndex].value;
e1 = document.getElementById("ToTime");
var totime = e1.options[e1.selectedIndex].value;
var Smonth = (SDate.getMonth() + 1);
  if (Smonth <= 9) {
    Smonth = "0" + Smonth;
}

 var Emonth = (EDate.getMonth() + 1);
 if (Emonth <= 9) {
     Emonth = "0" + Emonth;
 }

 var strtDate = SDate.getFullYear() + "-" + Smonth + "-" + SDate.getDate() + "T" + fromtime.substr(0, 2) + ":" + fromtime.substr(2, 2) + ":" + "00";
var EndDate = EDate.getFullYear() + "-" + Emonth + "-" + EDate.getDate() + "T" + totime.substr(0, 2) + ":" + totime.substr(2, 2) + ":" + "00";**

fetch XML code :

query = "" + "<fetch version='1.0' output-format='xml-platform' mapping='logical'                distinct='false'>" +
"<entity name='ccx_vitals'>" +
 "<attribute name='ccx_bpdiastolic' />" +
"<attribute name='ccx_bpsystolic'/>" +
"<attribute name='ccx_glucose' />" +
 "<attribute name='ccx_pulse' />" +
 "<attribute name='ccx_temperature' />" +
 "<attribute name='ccx_tempunitofmeasure' />" +
 "<attribute name='ccx_tempmeasuremethod' />" +
 "<attribute name='ccx_height' />" +
 "<attribute name='ccx_heightunittype' />" +
 "<attribute name='ccx_weight' />" +
 "<attribute name='ccx_weightunitofmeasure' />" +
 "<attribute name='ccx_bmi' />" +
 "<attribute name='ccx_painlevel' />" +
 "<attribute name='ccx_vitaldate' />" +
 "<attribute name='ccx_oxygen' />" +
 "<attribute name='ccx_heartrate' />" +
 "<attribute name='ccx_respiratoryrate' />" +
 "<attribute name='ccx_vitalsid' />" +
 "<attribute name='ccx_oxygensaturation' />" +
 "<attribute name='ccx_oxygendeliverydevice' />" +
"<attribute name='ccx_bpqualifier' />" +
 "<filter type='and'>" +
"<condition attribute='statecode' operator='eq' value='0' />" +
"<condition attribute='ccx_contact' operator='eq' value='" + clientId + "' />";
if (document.getElementById("FromDate").value != '' &&     document.getElementById("Todate").value != '')
{
query = query + "<condition attribute='ccx_vitaldate' operator='on-or-after' value='" +     strtDate + "'/>" +
"<condition attribute='ccx_vitaldate' operator='on-or-before' value='" + EndDate +         "'/>";
 }
query=query+ "</filter>" +
"<order attribute='ccx_vitaldate' descending='true' />" +
"</entity>" +
 "</fetch>";
 return query;

回答1:


Date Time is stored in UTC, but displayed in your local time zone. You're javascript will have to determine your timezone, and then perform the conversion to UTC, and then use that value in your FetchXml.

Check out these questions as the answer is the same, even though what they are trying to do is different:

  • CRM 2011, Date in plugin and DST
  • Date Showing Up Different in MS Dynamics CRM than that of SQL-Server
  • createdon field date-time format


来源:https://stackoverflow.com/questions/23039244/compare-datetime-issue-with-dynamic-crm-2013-datetime-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!