473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

PV function in Access

Does anyone know sql of the PV function in Access? (same function in
Excel)

In access the inputs are PV («rate», «nper», «pmt», «fv»,
«due») where rate = discount rate, nper = number of payments, pmt =
payment) other two are not required.

nper is allowed to be a number with decimals, not just an integer.

Seeking sql code which will replicate the above, including nper with
decimals allowed. Thanks.

Nov 20 '05 #1
4 3851
Assuming you mean SQL in JET, the expression service seems to be quite
happy to send PV off to VBA for evaluation. In other words one can
execute a query such as:
SELECT PV(0.08,12.768,PaymentAmount) FROM Table1
where PaymentAmount is a numeric field.

Nov 20 '05 #2
Thanks, but I do not mean sql in jet. SQL code in another sql
platform such as sql server. Or SQL in jet that would not use the
function pv but show the actual underlying code.

Nov 20 '05 #3
I think you will have to write your own in line function then, or
probably, better still, create a UDF in MS-SQL.
Perhaps, if you do a web search for Present Value you will find one
already created.

Nov 20 '05 #4
You could try this MS-SQL UDF which is something I cobbled together on
(this) Sunday morning BUT (trying to say this without offending)
If you can't write this yourself, can you apply it correctly in all
situations and should you?
I have tested it against the Excel function for !!!!!ONE!!!!! case; if
I were going to use it I would test it a few more thousand times.

ALTER FUNCTION dbo.PresentValue
(
@Rate smallmoney,
@Periods money,
@Payment money,
@FutureValue money = 0,
@Type int = 0
)
RETURNS money
AS
BEGIN
DECLARE @PresentValue money

/*
Deal with Nulls
*/
If @FutureValue IS NULL
SET @FutureValue = 0
IF @Type IS NULL
SET @Type = 0

/*
Type should be one or zero.
*/
IF @Type != 0 AND @Type != 1
SET @PresentValue = 0
ELSE
/*
This is just a port of the Excel function
without any shortcuts for Rate = 0 or FutureValue = 0,
or simplification.
*/
SET @PresentValue =
-(@Payment * (1 + @Rate * @Type)
* ((Power((1 + @Rate), @Periods) - 1) / @Rate)
+ @FutureValue) / Power((1 + @Rate), @Periods)
RETURN @PresentValue

END

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Martin Vorbrodt | last post by:
Example code in one of my books intrigues me: class B { public: B* Clone() const { B* p = DoClone(); assert(typeid(*p) == typeid(*this)); return p; }
7
by: Alex | last post by:
Hi all, I've found a module that I think will help me combine fields properly, but I'm unsure how to add or use it with Access 2000. Below is the module I'd like to add: ...
6
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the...
11
by: Yelena Varshal via AccessMonster.com | last post by:
Hello, I have a problem with one of msaccess.exe API calls that work on my desctop but does not work on the laptop from within MS ACCESS. There is a lot of differences between 2 computers...
3
by: william | last post by:
My situation is here: an array of two dimension can only be defined locally within a function(because the caller don't know the exact size ). Then the question is: how should the caller access...
9
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this...
12
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
1
by: seanmatthewwalsh | last post by:
Hi I have a website that uses an Access 2003 database. I have controls on my pages that are bound to SqlDataSources that pull data from this database. In a couple of them, I need to use the...
2
by: Immortal Nephi | last post by:
I design a class for general purpose. I do not allow a client to read or modify interface and implemention. I allow them to write a new non- member function outside of class' interface and...
7
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am using this code to get groups for a user and getting a error (5) on the GetAuthorizationGroups() function . There are two domains. This function works on the local domain but does not work...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.