Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Google Spreadsheet how can you query 'GoogleFinance' for a past exchange rate?

I'd like to know if it is possible to query a past exchange rate on Google Spreadsheet.

For example; using formula =GoogleFinance("CURRENCY:USDEUR") will return the USD/EUR rate at this present moment. How can you retrieve a historic rate?

like image 769
antr Avatar asked Dec 16 '13 09:12

antr


People also ask

How do I import a currency exchange rate into Google Sheets?

Select a cell which you want to place the result, type this formula =A2*GOOGLEFINANCE("CURRENCY:USDGBP") (in the formula, A2 is the cell value you use to convert, USD is the currency you want to convert, GBP is the currency you want to convert to). Then press Enter key, the result displays.

How do I get a stock price for a specific date using the GOOGLEFINANCE spreadsheet formula?

Type the following formula into the selected cell: “=GOOGLEFINANCE(“GOOG”, “price”, DATE(2022,1,1), DATE(2022,12,31), “DAILY”)”. The first parameter is the ticker symbol, which is the only required parameter.


4 Answers

In order to retrieve the historical rate, you have to use the following formula:

=GoogleFinance("eurusd","price",today()-1,today())

where today()-1, today() is the desired time interval, which can be explicitly defined as the static pair of dates, or implicitly, as the dynamically calculated values, like in the example above. This expression returns a two-column array of the dates and close values. It is important to care about the suitable cell format (date/number), otherwise your data will be broken.

If you want to get the pure row with the date and currency exchange rate without column headers, wrap your formula with the INDEX() function:

=INDEX(GoogleFinance("eurusd","price",today()-1,today()),2,)

To retrieve the exchange rate value only, define the column number parameter:

=INDEX(GoogleFinance("eurusd","price",today()-1,today()),2,2)

To get today's currency exchange rates in Google Docs/Spreadsheet from Google Finance:

=GoogleFinance("eurusd","price",today())

A shorter way to get today's rates:

=GoogleFinance("currency:usdeur")

P.S. There is also the way to get live currency exchange rate in Microsoft Excel.

like image 122
Mike Avatar answered Oct 16 '22 14:10

Mike


Try,

=GoogleFinance("usdeur","price",date(2013,12,1),date(2013,12,16))

Make sure that the dates are as per your spreadsheet settings.

Edit as comment, changed date for capturing single day data:-

Only with headers:

=INDEX(GoogleFinance("usdeur","price",date(2013,12,3),date(2013,12,4)),,2)

without headers:

=FILTER(INDEX(GoogleFinance("usdeur","price",date(2013,12,3),date(2013,12,4)),,2),INDEX(GoogleFinance("usdeur","price",date(2013,12,3),date(2013,12,4)),,2)<>"Close")
like image 26
Vasim Avatar answered Oct 16 '22 12:10

Vasim


The instructions for all related to googlefinance are in here: https://support.google.com/docs/answer/3093281

Remember the actual Google Spreadsheets Formulas use semicolon (;) instead of comma (,). Once made the replacement on some examples would look like this:

For a 30 day INDEX of USD vs EUR you should use (note that in the case of currencies they go together in the same first variable):

=INDEX(GoogleFinance(USDEUR;"price";today()-30;today());2;2)

TIP: You can get the graph over the entire size of the cell by simply changing INDEX for SPARKLINE, like this:

=SPARKLINE(GoogleFinance(USDEUR;"price";today()-30;today());2;2)
like image 10
DavidTaubmann Avatar answered Oct 16 '22 12:10

DavidTaubmann


Vasim's answer is excellent, however notice if you want the exchange date on that day only, you can omit the range and just specify the day such as the following

=FILTER(INDEX(GoogleFinance("usdeur","price",today()),,2),INDEX(GoogleFinance("usdeur","price",today()),,2)<>"Close")

like image 3
user56236 Avatar answered Oct 16 '22 13:10

user56236