Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Novice > Fwd: Adding to ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 3152 of 3191
Post > Topic >>

Fwd: Adding to a date

by harold.gimenez@[EMAIL PROTECTED] ("=?ISO-8859-1?Q?Harold_A._Gim=E9nez_Ch Jun 30, 2008 at 05:52 PM

Sorry, forgot to include the group in my reply...


---------- Forwarded message ----------
From: Harold A. Gim=E9nez Ch. <harold.gimenez@[EMAIL PROTECTED]
>
Date: Mon, Jun 30, 2008 at 5:51 PM
Subject: Re: [NOVICE] Adding to a date
To: Mike Ellsworth <younicycle@[EMAIL PROTECTED]
>


Intervals might help...for example:

timestamp '2001-09-28 01:00' + interval '23 hours' =3D timestamp
'2001-09-29 00:00:00'

Taken from here:
http://www.postgresql.org/docs/8.3/interactive/functions-datetime.html


On Mon, Jun 30, 2008 at 5:44 PM, Mike Ellsworth <younicycle@[EMAIL PROTECTED]
>
wrot=
e:
>
> I was beginning to create some financial functions for calculating
> Future Values, PV's, etc  -for basic retirement planning.
> example:
>
> CREATE OR REPLACE FUNCTION lotsa.FVPMT(payment double precision,
> interestRate double precision, periods double precision)
> RETURNS  double precision AS
> $BODY$
>  BEGIN
> return payment*(pow(1+interestRate, periods)-1)/interestRate;
> END;
> $BODY$
>  LANGUAGE 'plpgsql' VOLATILE
>
> periods seems to be a problem.  Usually, I'd be getting birth_date
> from a file, but I'm not finding a way to
> add 65 years - or 67 or whatever, to get the period between now (or an
> assumed date) and retirement.
>
> I'm hoping there is a way to:
> 1) Date of birth + xx years - with a result of date (Result 1)
> 2) Subtract now or an assumed date from Result 1 to get Result 2
> 3) Divide by ~ 365.25 for years, which would be 'periods' in the
function.
>
> I've gotten around it, but it sure seems pretty messy:
> Greatest(FVPMT(test_fv.pmt, test_fv.i_rate,
> (23741.25-(test_fv.start_date-test_fv.dob))/365.25),0)
>
> where the 23741.25 is 65* 365.25.
>
> Any help would be appreciated.  I've read all of what would seem to be
> appropriate.
> Doesn't mean I understood it, but I read it.
>
> I'm not concerned about being off by a day or 2.
> Small potatoes compared to the variations rate of return will undergo.
>
> Thanks
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice@[EMAIL PROTECTED]
)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice

--=20
Sent via pgsql-novice mailing list (pgsql-novice@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
 




 3 Posts in Topic:
Adding to a date
younicycle@[EMAIL PROTECT  2008-06-30 17:44:09 
Fwd: Adding to a date
harold.gimenez@[EMAIL PRO  2008-06-30 17:52:56 
Re: Adding to a date
scrawford@[EMAIL PROTECTE  2008-06-30 15:02:58 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Aug 21 18:09:52 CDT 2008.