Print

GetExchangeRate

The GetExchangeRate() function gets an exchange rate for given currencies from NBP (National Bank of Poland) quotation tables A or B. Lists of supported currency codes are:

  • Table A: AUD, BGN, BRL, CAD, CHF, CLP, CNY, CZK, DKK, EUR, GBP, HKD, HUF, IDR, ILS, INR, ISK, JPY, KRW, MXN, MYR, NOK, NZD, PHP, RON, SEK, SGD, THB, TRY, UAH, USD, XDR, ZAR;
  • Table B (available since 240331 AMODIT edition): AED, AFN, ALL, AMD, ANG, AOA, ARS, AWG, AZN, BAM, BBD, BDT, BHD, BIF, BND, BOB, BSD, BWP, BYN, BZD, CDF, COP, CRC, CUP, CVE, DJF, DOP, DZD, EGP, ERN, ETB, FJD, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HNL, HTG, IQD, IRR, JMD, JOD, KES, KGS, KHR, KMF, KWD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MZN, NAD, NGN, NIO, NPR, OMR, PAB, PEN, PGK, PKR, PYG, QAR, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SLE, SOS, SRD, SSP, STN, SVC, SYP, SZL, TJS, TMT, TND, TOP, TTD, TWD, TZS, UGX, UYU, UZS, VES, VND, VUV, WST, XAF, XCD, XOF, XPF, YER, ZMW, ZWL.

Syntax

GetExchangeRate(source, currencyFrom, currencyTo, [which = "mean"], [when = now()], dateFieldName)

Function arguments

  • source – (String) always „NBP”, other sources are not available right now;
  • currencyFrom – (String) a source currency. Either source or destination currency must me „PLN”;
  • currencyTo – (String) a destination currency. Either source or destination currency must me „PLN”;
  • which – (String) [optional] which exchange rate to get: „mean” – mid, „bid” – buying, „ask” – selling;
  • when – (DateNoTime) [optional] the latest exchange rate for a date <= when will be returned. Today by default, which means „last work day <= today”.
  • dateFieldName – (String) [optional] a field on the form into which the date of exchange rate will be saved.

Return value

The GetExchangeRate() function returns Decimal.
Returns a currency exchange rate on success and 0 (zero) on failure. In case you try to get exchange rate between the same currency (i.e. PLN to PLN) you will receive value of 1 (one).

Examples

Example 1

Mid exchange rate from EUR to PLN, obtained from NBP for the last workday (may be today).

GetExchangeRate("NBP", "EUR", "PLN")

Example 2

Bid exchange rate from PLN to USD, obtained from NBP for the last workday (may be today).

GetExchangeRate("NBP", "PLN", "USD", "bid")

Example 3

Ask exchange rate from EUR to PLN, obtained from NBP for the last workday (may be today). Exchange rate date will be saved in „dateFieldName” field.

GetExchangeRate("NBP", "EUR", "PLN", "ask", 2012-12-31, "dateFieldName")

Example 4

Gets the most current exchange rate (mean) from PLN to AED (UAE’s Dirham).

GetExchangeRate("NBP", "PLN", "AED", "mean", CurrentDateTime())

 

Czy artykuł był pomocny?
0 na 5 gwiazdek
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
How Can We Improve This Article?