【发布时间】:2012-05-29 23:23:57
【问题描述】:
编译以下 coe 总是会遇到同样令人沮丧的错误。我正在尝试将“createdon”字段与当前日期进行比较。我尝试了几种日期格式,但仍然无法正常工作...
错误详情:“23/05/2012 14:01:55 的日期时间格式无效”
代码sn-p:
DateTime d = DateTime.Now;
String.Format("{0:dd/MM/YYYY HH:mm:ss}", d);
FetchExpression fetch = new FetchExpression(@"
<fetch distinct='false' mapping='logical'>
<entity name='" + context.PrimaryEntityName + "'><filter type='and'><condition attribute='createdon' value='" + d + "' operator='ne'></condition></filter><link-entity name='new_contrats' alias='nombreligne' from='new_contratsid' to='new_contratsid'><filter type='and'><condition attribute='new_contratsid' value='" + contrats.Id + "' operator='eq'></condition></filter></link-entity></entity></fetch>");
任何帮助都会很棒!
【问题讨论】:
-
我认为该值存储在
UTC中,也许您需要使用.ToUniversal()或.UtcNow()将您的DateTime转换为 或者您应该尝试可排序的日期时间模式yyyy-MM-ddTHH:mm:ss -
+1 for yyyy-MM-ddThh:mm:ss... 这就是我使用的。
-
谢谢两位的回答,我已经尝试过.ToUniversal() 和.UtcNow(),只是尝试了可排序的日期时间模式,但仍然没有结果!
标签: c# plugins dynamics-crm-2011 fetchxml