Вопрос

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 !

Это было полезно?

Решение

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

Другие советы

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top