Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
SQL
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
Posted
Updated 4-Aug-14 23:12pm
v3
Comments
coded007 5-Aug-14 5:23am    
what is the help you need here ?
Amol_B 6-Aug-14 6:31am    
Do you need to calculate Due date based on Start Date ?
Neetin_1809 6-Aug-14 13:37pm    
do u want to display the complete schedule ?

1 solution

what kind of a help do you need?
Possibly Detect the no of installments generated through the frequency,and through the use of while loop.
You can insert one by one record into table.
 
Share this answer
 
Comments
NanaKwame 7-Aug-14 1:35am    
Please I wanted each scheduled date for payment. For instance if start date for payment is 05 August,2014 and End Date is 23 December,2014 and the frequency is weekly. I want the system to loop true and insert each due date payment into a different table as soon as the startDate and EndDate is supply. I hope this will help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900