GetExchangeRate

Gets exchange rate from NBP. Due to shut down of YAHOO Finance API only NBP is available right now.

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) Source currency. Either source or destination currency must me „PLN”
  • CurrencyTo – (String) 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] Newest exchange rate for date <= when will ne returned. Today by default, which means „last work day <= today”.
  • dateFieldName – (String) [Optional] Field into which the date of exchange rate will be saved.

Return value

This function returns Decimal.
Returns currency exchange rate on success and 0 on failure.

Examples

Example 1:
Mid exchange rate from EUR to PLN, obtained from NBP for the last workday (may be today) (Kurs średni Euro na ostatni dzień roboczy.)

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

Example 2:
Bid exchange rate from PLN to USD, obtained from NBP for the last workday (may be today) (1 / Kurs sprzedaży dolara na ostatni dzień roboczy.)

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. (Kurs kupna Euro na ostatni dzień roboczy mniejszy lub równy 2012-12-31.)

GetExchangeRate("NBP", "EUR", "PLN", "ask", 2012-12-31, "dateFieldName")
Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.