Home » RDBMS Server » Server Administration » Help : Date calculation
Help : Date calculation Tue, 04 January 2000 04:35
 Siby Thomas Messages: 2Registered: December 1999 Junior Member
How to write a function, to calculate maturity date from the following.
The parameters are - opening date , current date, number of periods (number), unit (like year, month,Quarter,day).
Does anyone know if such a script already exists? Or does anybody have any tips about the use of existing date functions.

Thanks
Re: Help : Date calculation [message #370601 is a reply to message #370593] Wed, 05 January 2000 06:16
 Paul Messages: 164Registered: April 1999 Senior Member
Siby,
Don't know of existing function, but it seems to be some fairly easy calculations -
new_date := your_date + n;
new_date := your_date - n;
where n is the number of days to add/subtract
where n is the number of months to add/subtract
either use add_months with (n * 3), if your definition of a quarter is 90 days,
or days with (n * 90), if you define a quarter as three months
If you use a 'house' definition of a year (I've seen both 360 and 364 day 'years') you can handle them like quarters ((n * 360) for example).
Hope this helps,
Paul
Re: Help : Date calculation - correction [message #370602 is a reply to message #370601] Wed, 05 January 2000 06:28
 Paul Messages: 164Registered: April 1999 Senior Member
Siby,
Oops, slight error, reverse the notes on adding quarters:
n*90 to add 90 days, add_months(date,(n*3) to add 3 months. Also (should be obvious), if you define a month as 30 days use n*30 with the days logic, rather than the add_months() function.
Paul
Thanks: Date calculation [message #370634 is a reply to message #370602] Wed, 12 January 2000 04:55
 Siby Messages: 1Registered: January 2000 Junior Member