array arFields

This method creates a new currency for the specified date. Prior to adding, verifies the availability of this currency for this day. Static method. Resets currency_rate cache if the adding is successful, resets the currency_id tagged cache.


arFields Associative array of new currency rate parameters in which keys are the parameter names and values are the parameter values.

The following keys are possible:
  • CURRENCY - the ID of currency for which a rate is added (required);
  • DATE_RATE - the date for which the rate is being added (required);
  • RATE_CNT - the number of currency units used to define the rate of exchange (for example, if CYP 10 equal to USD 21.58, 10 is the number of currency units) (required);
  • RATE - the default rate of exchange. (One of currencies within a site must equal to 1. Such currency is called a base currency. Other currencies are defined relative to the base currency.)

Return Values

Returns currency rate ID on success, or false otherwise. Error text is returned via $APPLICATION->GetException()


// Consider CYP a base currency.
// CYP rate for 10.08.2005 is 10 CYP for 21.58 USD

$arFields = array(
    "RATE" => 21.58    48.1756,
    "RATE_CNT" => 10,
    "CURRENCY" => "CYP",  "ISK",
    "DATE_RATE" => "10.08.2005"

if (!CCurrencyRates::Add($arFields))
    echo "error adding rate";
© «Bitrix24», 2001-2024