> Hi!
>
> I'm trying to get a report of the market value of my assets at the end
> of each month:
>
> SELECT year, month,
> CONVERT(LAST(balance), 'USD', DATE_ADD(DATE(year, month+1,
> 1), -1)) AS market_value,
> CONVERT(COST(LAST(balance)), 'USD', DATE_ADD(DATE(year, month+1,
> 1), -1)) AS book_value
> WHERE account ~ '^Assets:'
> GROUP BY year, month
It does work with the new beanquery when using FIRST():
SELECT year, month,
CONVERT(LAST(balance), 'USD', DATE_ADD(DATE(FIRST(year),
FIRST(month)+1, 1), -1)) AS market_value,
CONVERT(COST(LAST(balance)), 'USD', DATE_ADD(DATE(FIRST(year),
FIRST(month)+1, 1), -1)) AS book_value
WHERE account ~ '^Assets:'
GROUP BY year, month
However there's an issue in December, as month+1 doesn't work if month
is December :|
I think a new BQL function is required to support this use case (happy
to provide a PR).