Have you tried FROM CLOSE ON <date>

See https://beancount.github.io/docs/beancount_query_language.html for more
on how this works.

On Sat, May 29, 2021, 13:12 Mark Lodato <[email protected]> wrote:

> Oops, I sent out that email in haste. I didn't mean it for it to sound so
> demanding.
>
> If anyone wouldn't mind helping construct such a query, I'd appreciate it!
>
> On Sat, May 29, 2021, 4:02 PM Mark Lodato <[email protected]> wrote:
>
>> I can't figure out how to write a query that prints the aggregate balance
>> of an account subtree as of a given date, converted to USD using the price
>> as of that date. Example data:
>>
>> $ cat >test.bean <<EOF
>> plugin "beancount.plugins.auto_accounts"
>> 2020-01-01 * "Open"
>>   Assets:Bank:AAA 100 AAA
>>   Assets:Bank:BBB 100 BBB
>>   Income:Work
>> 2021-01-01 price AAA 1 USD
>> 2021-01-01 price BBB 10 USD
>> 2021-01-02 price AAA 2 USD
>> 2021-01-02 price BBB 20 USD
>> 2021-01-03 price AAA 3 USD
>> 2021-01-03 price BBB 30 USD
>> EOF
>> $ bean-query test.bean 'SELECT convert(units(sum(position)), "USD") AS
>> value WHERE account ~ "Assets:Bank"'
>>  value
>> --------
>> 3300 USD
>>
>> I'd like to be able to specify a date and get the balance at the end of
>> that date, e.g. 2021-01-02 => 2200 USD. I tried using "FROM DATE =
>> 2021-01-02" or "FROM DATE <= 2021-01-02" but it doesn't affect the result.
>>
>> Thank you in advance,
>> Mark
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Beancount" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/beancount/yCPa_tlF2-4/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/beancount/a1cfbd22-e495-40e8-b6ea-055fd9227d47n%40googlegroups.com
>> <https://groups.google.com/d/msgid/beancount/a1cfbd22-e495-40e8-b6ea-055fd9227d47n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Beancount" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/CAHREChjkG%3Dy7pBKOuYMC4m6OzHfsx-4uTDdWx3DXLksFExdW2g%40mail.gmail.com
> <https://groups.google.com/d/msgid/beancount/CAHREChjkG%3Dy7pBKOuYMC4m6OzHfsx-4uTDdWx3DXLksFExdW2g%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CACGEkZsXDHc6g5H9ap4%2B8P5UocSA6PZBGPzr3vro9enoECK7tQ%40mail.gmail.com.

Reply via email to