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 > Re: Adding to a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 3152 of 3323
Post > Topic >>

Re: Adding to a date

by scrawford@[EMAIL PROTECTED] (Steve Crawford) Jun 30, 2008 at 03:02 PM

Mike Ellsworth wrote:
> I was beginning to create some financial functions for calculating
> Future Values, PV's, etc...
>
> 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
>   
Problems like 1 and 2 are easy - use "intervals".

select '1943-06-30'::date + '65 years'::interval;
2008-06-30 00:00:00

select current_date + '65 years'::interval;
2073-06-30 00:00:00


> 3) Divide by ~ 365.25 for years, which would be 'periods' in the
function.
>   

select ('2008-06-30'::date - '1943-06-30'::date)/365.25;

65.0020533880903491

Though there may be a better method for this. I'd need to poke around in 
the date arithmetic.

Cheers,
Steve


-- 
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 Fri Dec 5 6:05:04 CST 2008.