createdon field date-time format

拟墨画扇 提交于 2019-12-14 03:57:15

问题


Compiling the following coe always get the same frustrating mistake. I'm trying to compare a "createdon" field to a the present date. I've tried several date format but stil not working...

Error detail : "The date-time format for 23/05/2012 14:01:55 is invalid"

Code snippet:

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

Any help would be great !


回答1:


My blog posting here might help. Basically, UTC format but originating user's local offset may effect the underlying value in the database.




回答2:


It may be easier to work in either Linq to CRM or Query Expressions rather than Fetch XML. You don't have to worry about the formatting since you're working with objects.



来源:https://stackoverflow.com/questions/10719496/createdon-field-date-time-format

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