Bean-query DATE() function not working

26 views
Skip to first unread message

Andrzej Kotulski

unread,
Jan 18, 2020, 10:43:15 AM1/18/20
to bean...@googlegroups.com
When I try to run a date() function it doesn't work in bean-query.
Instead, I get following error:

beancount> select day(DATE('2019-05-01')) limit 10;
ERROR: Invalid type for argument 0 of Day: found <class
'beancount.core.inventory.Inventory'> expected <class 'datetime.date'>.

To reproduce it, it's enough to run this query on an empty beancount file.
I tried to understand why it's happening but I had no luck. Am I doing
something wrong or is it an unintended behavior?

Justus Pendleton

unread,
Jan 19, 2020, 8:51:33 AM1/19/20
to Beancount


On Saturday, January 18, 2020 at 10:43:15 PM UTC+7, Andrzej wrote:
When I try to run a date() function it doesn't work in bean-query.
Instead, I get following error:

beancount> select day(DATE('2019-05-01')) limit 10;
ERROR: Invalid type for argument 0 of Day: found <class
'beancount.core.inventory.Inventory'> expected <class 'datetime.date'>.

The documentation for BQL says

"You can parse a date with the #”...” syntax; this uses Python’s dateutil module and is pretty liberal in the formats it accepts."

So you'd actually write day(#'2019-05-01'). I don't know why you'd want to write a query like that, though. It is just going to print the number "1" for every transaction in your file, up to a maximum of 10.
Reply all
Reply to author
Forward
0 new messages