Question: We have a legacy database (SQLServer 2008) with thousands of rows in it. Each record has a logdate field which is a date but stored as a varchar in the format `21/04/2010 16:40:12`.

We only need to return the rows where the logdate is in the future, and order them by date. We could pull back all the rows and filter on the server but this seems wrong and won't scale. 

**Is there a way of doing the filtering and ordering in Entity Framework 4.** 

This is what we thought might work but it's failed. 

```
from c in db.changes
where [DateTime]c.logdate > DateTime.Today()
orderby [DateTime]c.logdate
select c;

```

Any help is appreciated.

Answer: 
You can't parse a string into a date on the DB server with any built-in L2E function.

You can:

1. map a DB function yourself,
2. write SQL and execute it with `ObjectContext.ExecuteStoreQuery`, or
3. fix the metadata.

I'd pick the latter, if it were me.
The order in a varchar field will be considerably different than the order in date field. Fix your structure to correctly store dates or add an additional date field that is populated through a trigger. Likely you have bad dates in there as well since there are no controls on a varchar field to diallow dates from being put in. You will need to fix these as well.