I need to be able to provide a report with a next due date for payment date. The user is able to see next due date for payment. This can be done by specifying the frequency (daily, weekly, monthly,yearly), a "multiplier" (i.e. every 3 days, every 2 weeks, every 6 months, etc...) and a start date must be supply from the front end to the SQL. After the calculation I want it to insert the records into a scheduleTable which presented the user as a report. Example for schedule table
Create Table ScheduledDate
(
LoanID SmallInt Not Null,
LenderName Varchar(30)Not Null,
ScheduledDates DateTime Not Null
)
Create Proc prcCalculateScheduleDate
(
@LoanID SmallInt,
@StartDate DateTime,
@EndDate DateTime
)
As
Begin
Select 0 n, LOANID,REPAYMENT_STARTDATE,Frequency,Multiplier From LOANS_REPAYMENT_PLAN
Where LOANID = @LoanID AND REPAYMENT_STARTDATE=@StartDate AND REPAYMENT_ENDDATE = @EndDate
Begin
Select n+1 n,
Case[Frequency]
When 'Daily' Then DateAdd(Day,Multiplier,ScheduleDate)
When 'Weekly' Then DateAdd(Week,Multiplier,ScheduleDate)
When 'Monthly' Then DateAdd(Month,Multiplier,ScheduleDate)
When 'Yearly' Then DateAdd(Year,Multiplier,ScheduleDate)
End As ScheduleDate,
[Frequency],
[Multiplier]
From LOANS_REPAYMENT_PLAN
Insert Into ScheduledDate
Group By LOANID,LENDER_NAME
End
Any help will be appreciated. NanaKwame