I'm having hard times writing this T-SQL query, so I'd appreciate some help. 

There is a table that looks like this:

> 
> id | idd (number) | created\_on (datetime) | property | old\_value | new\_value | ... other
> 
> 
> 

This is a history log reflecting changes made to fields of some objects.

What I need to be able to do is to choose for every object the latest state of its given property to a given date.

Suppose the data looks like this: 

```

 1 | 10 | 2014-01-01 | 14 | null | 5  
 2 | 10 | 2014-01-03 | 14 | 5    | 10  
 3 | 10 | 2014-01-05 | 14 | 10   | 8  
 4 | 11 | 2014-01-02 | 14 | null | 7  
 5 | 11 | 2014-01-08 | 14 | 7    | 25  
 ...

```

This way if I have to select the latest states of property `14` at `2014-01-10`, the result would be:

```

 3 | 10 | 2014-01-05 | 14 | 10   | 8  
 5 | 11 | 2014-01-08 | 14 | 7    | 25 

```

If I have to select the latest states of property `14` at `2014-01-04`, the result would be:

```

 2 | 10 | 2014-01-03 | 14 | 5    | 10
 4 | 11 | 2014-01-02 | 14 | null | 7 

```

What I've managed so far is to select the required values for a single object, which is quite easy, but I don't know how to extend the query to include all of them.