Home » SQL & PL/SQL » SQL & PL/SQL » Duplicating Excel COUPNCD function in PLSQL.
Duplicating Excel COUPNCD function in PLSQL. [message #671525] Tue, 04 September 2018 00:44 Go to next message
SATHISHENU
Messages: 5
Registered: November 2017
Junior Member
Sub : Duplicating Excel COUPNCD function in PLSQL.

Friends, I am in the need of COUPNCD PLSQL SOURCE CODE for my Project. Experts, Please do help me in this. Thanks in Advance.
Re: Duplicating Excel COUPNCD function in PLSQL. [message #671526 is a reply to message #671525] Tue, 04 September 2018 00:50 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

And what does COUPNCD do?

Re: Duplicating Excel COUPNCD function in PLSQL. [message #671527 is a reply to message #671525] Tue, 04 September 2018 00:55 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

From your previous topic with same kind of question:

John Watson wrote on Mon, 27 November 2017 12:23
Welcome to the forum. Please read our OraFAQ Forum Guide and How to use [code] tags and make your code easier to read

If you post the formula that this YIELD function calculates, perhaps someone can help. Or you can write the code yourself. Or perhaps there is a built-in function that does it, Oracle does include many financial calculation functions.

In addition, if you don't feedback and thank people who spend time to help yo you won't have further help.

Re: Duplicating Excel COUPNCD function in PLSQL. [message #671528 is a reply to message #671527] Tue, 04 September 2018 01:02 Go to previous messageGo to next message
SATHISHENU
Messages: 5
Registered: November 2017
Junior Member
Hi Friend Sorry for that.

COUPNCD Details :


The COUPNCD function is one of the financial functions. It is used to calculate the next coupon date after the settlement date.

The COUPNCD function syntax is:

COUPNCD(settlement, maturity, frequency[, [basis]])

where

settlement is the date when the security is purchased.

maturity is the date when the security expires.

frequency is the number of interest payments per year. The possible values are: 1 for annual payments, 2 for semiannual payments, 4 for quarterly payments.
Re: Duplicating Excel COUPNCD function in PLSQL. [message #671530 is a reply to message #671528] Tue, 04 September 2018 01:11 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Do you REALLY think this is sufficient to provide PL/SQL code?

Re: Duplicating Excel COUPNCD function in PLSQL. [message #671532 is a reply to message #671530] Tue, 04 September 2018 01:14 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

https://support.office.com/en-us/article/coupncd-function-fd962fef-506b-4d9d-8590-16df5393691f

Re: Duplicating Excel COUPNCD function in PLSQL. [message #671533 is a reply to message #671532] Tue, 04 September 2018 01:21 Go to previous messageGo to next message
SATHISHENU
Messages: 5
Registered: November 2017
Junior Member
Hi, I am expecting PLSQL CODE to duplicate the COUPNCD. Thats it. Thanks for your questions and support. Since i dont have idea to convert, asked help with experts. If u have idea or u have code to write a PLSQL code u can help me. Thanks in advance.

Reference : https://support.office.com/en-us/article/coupncd-function-fd962fef-506b-4d9d-8590-16df5393691f

[Updated on: Tue, 04 September 2018 01:22]

Report message to a moderator

Re: Duplicating Excel COUPNCD function in PLSQL. [message #671534 is a reply to message #671533] Tue, 04 September 2018 01:33 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

"u"? but U is dead.

Re: Duplicating Excel COUPNCD function in PLSQL. [message #671535 is a reply to message #671533] Tue, 04 September 2018 03:46 Go to previous messageGo to next message
John Watson
Messages: 8922
Registered: January 2010
Location: Global Village
Senior Member
You (not "u". Abbreviations like that are seriously bad form on a professional forum. Save them for your twittering) have to explain the algorithm that COUPNCD implements. The mathematics behind it: the input, the output, and how to calculate one from the other.
Re: Duplicating Excel COUPNCD function in PLSQL. [message #672418 is a reply to message #671528] Sun, 14 October 2018 12:48 Go to previous message
Barbara Boehmer
Messages: 9077
Registered: November 2002
Location: California, USA
Senior Member
The following works for actual/actual day count basis (1), as demonstrated using the example in the previously provided link.

SCOTT@orcl_12.1.0.2.0> CREATE OR REPLACE FUNCTION couponcd
  2    (p_settlement IN DATE,
  3  	p_maturity   IN DATE,
  4  	p_frequency  IN INTEGER)
  5    RETURN DATE
  6  AS
  7  BEGIN
  8    -- check for input errors:
  9    IF p_frequency NOT IN (1, 2, 4) THEN
 10  	 RAISE_APPLICATION_ERROR (-20001, 'Frequency must be 1 or 2 or 4!');
 11    END IF;
 12    IF TRUNC (p_settlement) >= TRUNC (p_maturity) THEN
 13  	 RAISE_APPLICATION_ERROR (-20002, 'Settlement cannot be >= maturity!');
 14    END IF;
 15    -- calculate and return next coupon date:
 16    RETURN ADD_MONTHS
 17  		(TRUNC (p_maturity),
 18  		 ((12 / p_frequency) * TRUNC (MONTHS_BETWEEN (p_settlement, p_maturity) / (12 / p_frequency))));
 19  END couponcd;
 20  /

Function created.

SCOTT@orcl_12.1.0.2.0> SHOW ERRORS
No errors.
SCOTT@orcl_12.1.0.2.0> SELECT couponcd
  2  	      (TO_DATE ('01-01-2011', 'DD-MM-YYYY'),
  3  	       TO_DATE ('15-11-2011', 'DD-MM-YYYY'),
  4  	       2)
  5  FROM   DUAL
  6  /

COUPONCD(TO
-----------
15-MAY-2011

1 row selected.
Previous Topic: Calculate problem , help me
Next Topic: Help with bitmap join indexes
Goto Forum:
  


Current Time: Thu Mar 28 12:45:57 CDT 2024