C# or SQL Server - How to get earliest or lastest date from multiple date tables?
Im not sure if the title fully explains what I am after here so let me try explain in a little more detail...

I need to be able to create an table that displays this...

![Dates Example][1]

Tables:

 1. Items (every time this item was installed and removed)
 2. Supplier (Every time the supplier was used with the item)
 3. Rate (rate for the supplier)

It needs to be able to:

 1. Get the ranges in the period selected
 2. Get the earliest date from the tables as the start date
 3. Get the latest date

If the start dates are all before the start period and all the end dates are after the end period then it will be a simple single line. But any dates that start or end in the middle of the period then set relevant dates for that line and get the next start date after previous line end.

I have done the entire program using Linq apart from this and I have something that looks like it works but Im really not happy with the way Iv done it.

My questions are... whats an elegant way of dealing with these dates? And should I be using C# or SQL Server for best result?


  [1]: http://i.stack.imgur.com/VlEaG.png
C# or SQL Server - How to get earliest or lastest date from multiple date tables?
===

Im not sure if the title fully explains what I am after here so let me try explain in a little more detail...

I need to be able to create an table that displays this...

![Dates Example][1]

Tables:

 1. Items (every time this item was installed and removed)
 2. Supplier (Every time the supplier was used with the item)
 3. Rate (rate for the supplier)

It needs to be able to:

 1. Get the ranges in the period selected
 2. Get the earliest date from the tables as the start date
 3. Get the latest date

If the start dates are all before the start period and all the end dates are after the end period then it will be a simple single line. But any dates that start or end in the middle of the period then set relevant dates for that line and get the next start date after previous line end.

I have done the entire program using Linq apart from this and I have something that looks like it works but Im really not happy with the way Iv done it.

My questions are... whats an elegant way of dealing with these dates? And should I be using C# or SQL Server for best result?


  [1]: http://i.stack.imgur.com/VlEaG.png