Hi all I have a task where I have to calculate a price across multiple date ranges and I am stuck on how I would do it.
I have query that returns a set of date ranges and a price for each rage the ranges are sequential and are UK dates & currency
FromDate ToDate PricePerDay
01/05/2013 06/05/2013 £7
07/05/2013 20/05/2013 £12
The query has 2 parameters: @date - which is a day the client wants training. @NumberOfDays - which is the number of days.
Now if the client submits the @date = 02/05/2013 and number of NumberOfDays = 2 the query will only return the first line and its fairly easy to read the data back and say ok the total price will be 2x£7.
But if the client submits @date = 04/05/2013 and number of NumberOfDays = 7 then it will return both lines above and I will have to calculate as follows
3 Days @ £7 and 4 days @ £12 because the date the client selected crosses both ranges.
I have to do this in a VB.net class (business Logic Class) company policy that DB is storage only and should not define business rules.
Any help or tips would be appreciated on this.
Jason