473,847 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3893
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.PresentValu e
(
@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
7328
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
781
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: http://www.mvps.org/access/modules/mdl0008.htm In Access, I goto Modules and create new. Leaving 'Option Compare Database' on top I paste the module code in and save - naming it fConcatFld. It saves fine, but when I use fConcatFld in my query, like below:
6
4414
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 same invocation from a DistantlyRelated class. What actually happened was that the compiler produced: error C2247: 'A::function' not accessible because 'CloselyRelated' uses 'private' to inherit from 'A' I'm guessing that the above compiler...
11
6645
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 including one running Office 2000 and another running Office 2003. This code was created by a previous developer. I need to find the description and parameters of the API calls. I found the article ...
3
1877
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 this array for future use? The code is: ********************** caller() {
9
3281
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 function are of type int. (My question has nothing to do with the definition of the function foo, so don't bother about it.) If I call the function as: foo(2,3,4,5,6,7,8);/*More arguments than expected*/
12
3027
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. The global variables and global functions are hidden to prevent from accessing by the programmers. All global functions share global variables. Only very few global functions are allowed to be reusability for the programmers to use. Few...
1
4636
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 replace function to replace some text in the results. Access' REPLACE function is only available if executed within the environment, as it's a VBA function, not a SQL function. So how can I implement this is the EASIEST possible way? I don't to...
2
2434
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 implmention. The problem is that non-member function cannot access private data member. The friend keyword is not the solution. I am aware that friend keyword allows the non-member function to access private data member. If you define more than...
7
16349
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 on the other domain. Other functions work on the other domain like get all the users and get all the groups and I can validate users on the other domain so I think I am communciating with the other domain OK just not with the...
0
10978
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10643
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10705
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9477
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7050
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5716
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5907
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.