将日期时间问题与动态CRM 2013日期时间数据进行比较 [英] Compare Datetime issue with dynamic CRM 2013 datetime data

查看:79
本文介绍了将日期时间问题与动态CRM 2013日期时间数据进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法通过使用Dynamic CRM 2013补偿日期时间来获取日期。
下面的时间格式正在我的代码中使用,即使我使用YYYY-MM-DD HH:MM格式化其仅基于日期的数据也是如此不考虑时间。
可以对此有任何想法。

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";**

获取XML代码:

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;


推荐答案

日期时间存储在UTC中,但显示在您的当地时区。您使用的是JavaScript,必须确定您的时区,然后执行到UTC的转换,然后在FetchXml中使用该值。

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

这篇关于将日期时间问题与动态CRM 2013日期时间数据进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆