# NEST search -\> String was not recognized as a valid DateTime

**URL:** <https://discuss.elastic.co/t/nest-search-string-was-not-recognized-as-a-valid-datetime/98237>\
**Category:** Elasticsearch\
**Created:** [August 24, 2017, 1:09pm UTC](https://discuss.elastic.co/t/nest-search-string-was-not-recognized-as-a-valid-datetime/98237 "2017-08-24T13:09:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![agonzalez](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@agonzalez](https://discuss.elastic.co/u/agonzalez)\
**Post date:** [August 24, 2017, 1:09pm UTC](https://discuss.elastic.co/t/nest-search-string-was-not-recognized-as-a-valid-datetime/98237/1 "2017-08-24T13:09:57Z")

</div>

i have been using this NEST search for months and has been working great, but now i am getting this error and doesnt return any document. I guess some new document has a invalid timestamp value but why one corrupt document makes everything fails?

ERRROR:  
Elasticsearch.Net.UnexpectedElasticsearchClientException: 'String was not recognized as a valid DateTime.'

QUERY:  
var result = elk.Search(x =\> x  
.From(0)  
.Index("alerts-\*")  
.AllTypes()  
.Size(Settings.n\_docs)  
.Query(q =\>  
q.QueryString(qs =\> qs.Query(query\_string)))  
.Sort(ss =\> ss.Descending(p =\> p.timestamp))  
);

AlertDto

public class UebAlertDto  
{  
public DateTime timestamp { get; set; }  
public DateTime created { get; set; }  
public int id { get; set; }  
public string message { get; set; }  
}

If i convert created to string it returns docs, so looks like some document has a created invalid, how can i find the incorrect ones or make NEST ignore them and return good ones?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 21, 2017, 1:10pm UTC](https://discuss.elastic.co/t/nest-search-string-was-not-recognized-as-a-valid-datetime/98237/2 "2017-09-21T13:10:04Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
