# TimeArray indexing

**URL:** https://discourse.julialang.org/t/timearray-indexing/79582
**Category:** New to Julia
**Created:** [April 16, 2022, 10:32pm UTC](https://discourse.julialang.org/t/timearray-indexing/79582 "2022-04-16T22:32:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chadagreene](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chadagreene/32/34924_2.png) [@chadagreene](https://discourse.julialang.org/u/chadagreene)
#### Post date: [April 16, 2022, 10:32pm UTC](https://discourse.julialang.org/t/timearray-indexing/79582/1 "2022-04-16T22:32:23Z")

</div>

I’m playing around with the MarketData package as a way to learn Julia. Now I’ve run into a simple question: How do I access the actual number inside a TimeArray?

I’m following the MarketData example to get the daily closing price of Apple’s stock:

```julia
using MarketData, TimeSeries
AAPL = yahoo(:AAPL)

```

That works great. I can see a full time series of daily closing prices in a column called `AdjClose`. Now I would like to plot the price history as a percentage of the most recent closing price. The mathematical formula for that is easy, and I think it _should_ be possible to calculate it like this:

```julia
price_percent = 100 .* AAPL[:AdjClose] ./ AAPL[:AdjClose][end]

```

That is, the full time series, divided by the most recent closing price. The problem is, the most recent closing price, which I attempt to acces by `AAPL[:AdjClose][end]`, is not a scalar, so I can divide the full time series by it:

 ![Screen Shot 2022-04-16 at 3.30.44 PM](https://global.discourse-cdn.com/julialang/original/3X/d/0/d0d4170f7e542cef5fd287742f1deef3c953c2af.png)

My question is how do I access that `165.29` value so I can divide the entire time series by it?

---

<div class="post-metadata">

### Author: ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)
#### Post date: [April 17, 2022, 7:34am UTC](https://discourse.julialang.org/t/timearray-indexing/79582/2 "2022-04-17T07:34:47Z")

</div>

You could use a [field getter function](https://juliastats.org/TimeSeries.jl/latest/timearray/#Fields-getter-functions-1)

```julia
price_percent = 100 .* AAPL[:AdjClose] ./ values(AAPL[:AdjClose])[end]

```

---

<div class="post-metadata">

### Author: ![chadagreene](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chadagreene/32/34924_2.png) [@chadagreene](https://discourse.julialang.org/u/chadagreene)
#### Post date: [April 17, 2022, 1:01pm UTC](https://discourse.julialang.org/t/timearray-indexing/79582/3 "2022-04-17T13:01:25Z")

</div>

Brilliant, that worked perfectly. Thanks @goerch!
