TOPIC: summarize a date field by month/year?
summarize a date field by month/year? 10 Months, 3 Weeks ago
I want to total some values in a table that has a date/time field. I want to summarize by month/year. The only way I was able to make this work was to add a new field to the table in question, L_flight_monthyear and add a rule:


function() {
  return .l_flight_at.NoTime().Replace(day: 1)

then I could issue:


logbook summarize l_flight_monthyear, total abc, total def

Is there an easier way to do this? I will want to summarize by week number and by year also, thus, do I have to create a field returning each of these values?

Re:summarize a date field by month/year? 10 Months, 3 Weeks ago
There are a few ways to handle it.

- You can add rule fields (not stored) to your tables. You do this by capitalizing the field when you create it.
e.g. alter mytable create (Year_month)

- You can extend a rule field
e.g. mytable extend year_month

These two would require Rule_year_month

- You can make a function and extend with that
e.g. mytable extend year_month = YearMonth(mydate)

But one way or another, you do need to introduce fields for the values you want to summarize by.