Solved

# Finance Charge Computation

Posted on 2004-11-14
541 Views
I am trying to create a statement to send to customers.
I would like the statement to include a finance charge.
The underlying recordset of my report returns a row for each outstanding invoice.

The finance charge computation is like this for each line:
BalanceDue * (InvoiceDate - CurrentDate) \ 30 * MonthlyInterestRate
(I would like to use integer division if possible - hence the backslash before the 30)

I'm not sure how to do this inside an SQL statement (or if it can be done). I need to get it back with my recordset so that my report writer (MS Access) can total it.

The main issues:
1. How to include the computation overall - can something this complex be done?
2. How to get the date difference in DAYS (not microseconds since 1900, or however it stores it).
3. How to refer to CurrentDate.
4. Can integer division be used?

Thanks very much.
Ted
0
Question by:tk3
1 Comment

LVL 75

Accepted Solution

1. Yes.
2. Use the DATEDIFF() function with "day" as the DatePart.
3. Use the GETDATE() function.
4. Yes, but not with "\".  Use the CAST function to convert to an integer as in:
BalanceDue * CAST(InvoiceDate - CurrentDate As Integer) / 30 * MonthlyInterestRate
0

## Featured Post

### Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.