문제

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