I have an event-receiver set up for sharepoint that runs a query against Oracle and then parses the returned date string.

The SQL SELECT statement is built like this :

TO_CHAR (TRUNC (dateinfo), 'dd.mm.yyyy')

And the C# code:

DateTime.ParseExact(currentFieldValue, "dd.mm.yyyy", null);

I´ve also set up logging, and it states in the logs that when trying to parse something seemingly correct like "28.11.2013" it gets the following error: "String was not recognized as a valid DateTime."

And this seems to only happen with multiple multiple simultaneous "ItemAdded" triggered, but not always, sometimes 5 "ItemAdded" events fail, sometimes 10 of them go through fine.

Has anyone encountered something like this or has any idea what could be the cause, what to look for?

1 Answer 1


Please try .Trim() method.

DateTime.ParseExact(currentFieldValue.Trim(), "dd.mm.yyyy", null);

If it does not work then refer below post https://stackoverflow.com/questions/1368636/why-cant-datetime-parseexact-parse-9-1-2009-using-m-d-yyyy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.