0
最近,我试图让在发票实体throuhg插件从自定义字段datetime值,发现它在CRM表单中显示的日期之前返回了一天。对于incstance,我进入“2013年7月1日”,在我的C#下面的代码返回“2013年6月30日”:日期时间插件CRM 2011
EntityReference eRef = new EntityReference(localContext.PluginExecutionContext.PrimaryEntityName, localContext.PluginExecutionContext.PrimaryEntityId);
var invoice = localContext.OrganizationService.Retrieve(eRef.LogicalName, eRef.Id, new ColumnSet(true));
string start = ((DateTime)invoice["revg_startdate"]).ToString(); //here I get 6/30/2013
然后我检查的实际日期时间相关MS SQL表,它会持续整整一天前,“二零一三年六月三十零日”
的日期,时间和时区的服务器上,我的电脑和CRM绝对相同。
为什么CRM保持并显示不同的日期?
完美的答案,+1 –
它太容易被我这么明显。谢谢,Svendberg – Gostapko
确保如果确实使用'.ToLocalTime()'调用,那么您知道您正在运行插件的服务器的时间。不是用户的时间。如果您想将UTC时间转换为用户的时间,请参阅此答案:http://stackoverflow.com/questions/11364982/server-side-fetchxml-returns-different-results/11367508#11367508 – Daryl