September 28, 2009 at 7:03 am
Hi
I thought this would be really easy but it's much harder than I expected !
I have a table of interest rates that span dates eg:
Int Rate start_date end_date
10 '2009-09-01' '2009-12-31'
8 '2009-08-01' '2009-08-31'
6 '2009-07-01' '2009-07-31'
What I need to do is send in a date of say 10th July 2009 and for the query to calculate the interest over the periods the dates hit. So in this example it would return 28 days @ 10% + 31 days @ 8% + 21 days @ 6% (given today as the 28th Sept)
I thought I had it with a case statement that works out the date and then does the calculations but I've just realised it's wrong. Now I can't seem to bend my head around the conditions I need to hit the right date periods.
Does anyone have any tipes of pointers to standard ways of bdoing this ? I would have thought it would be popular in banking calcs ?
September 28, 2009 at 7:53 am
Think I've sorted it now -
I can't put the SQL up as I'm working with MySQL (I know, I normally work with SQL but on this job I have to work with MySQL).
What I was missing was a special case for when the difference in dates (in days) between now and the reference date is less that the difference in days between the start of the interest period and now().
Clear as mud 😉
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply