Results 1 to 4 of 4
  1. #1
    sqlhell is offline Novice
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Posts
    1

    How Does Access calculate Present Value (PV)

    I just spent waay too much time trying to figure out a SQL translation of Access and Excel's present value function. I'm posting the solution here to save somebody else some time hopefully.



    I found a solution here: http://bytes.com/topic/access/answer...unction-access


    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

  2. #2
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    Correct me if I'm wrong but this code looks like a SQL Server cursor or SQL Server stored procedure, not vba coding.

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Not only that, but I'm wondering if this is the same ''SQL Hell'' that is a member of AWF. It certainly doesn't look like it from the elegance of the post!

  4. #4
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    Ha! Good one.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-23-2010, 07:33 AM
  2. Not present = red text
    By carstenhdk in forum Forms
    Replies: 6
    Last Post: 05-21-2010, 06:32 AM
  3. Replies: 1
    Last Post: 03-09-2010, 10:23 AM
  4. present date in data field
    By johnkl49 in forum Access
    Replies: 2
    Last Post: 09-14-2009, 04:18 PM
  5. Replies: 2
    Last Post: 07-31-2009, 06:56 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums