What I’m trying to do
I wanna find out the amount of time I have spent playing Red Dead Redemption 2
- “RDR2” only appears in my daily note in the overview section, indicating the amount of time I have spent playing the game throughout the whole day.
- Summing the duration of RDR2 across all my daily notes will give me the time I have spent playing this game in my lifetime, which is what I want to find out.
Sort file.name desc
Things I have tried
- I tried “group by” but that didn’t work
Group by RDR2
Sort file.name desc
I apologize for not being much of a help, I am a noob, nothing much came to my mind. I thought about sum function but I don’t know how it works.
If you know Python, I wonder if a plugin like Jupyter or Code Emitter (both available in the Community Plugins list) would let you operate on the data in that manner.
I would recommend reading the documentation to help you figure things out.
This should work (of course change accordingly):
sum(rows.RDR2) AS "RDR2"
GROUP BY true
You will propably also need to filter out anything that isn’t a number.
You’ve got some non-duration values in there, which could cause issues when adding up the total, so here’s a query to list those:
AND typeof(RDR2) != "duration"
Hopefully this just list out those few text variants in there, but I’m a little “worried” about that multi-valued variant in there.
The main query, untested but hopefully working, is as follows:
TABLE WITHOUT ID
sum( filter(flat(rows.RDR2), (r) => typeof(r) = "duration" )) as "Total playing time"
GROUP BY true
The trick here is to first select only the files having the field, and then group everything into
rows.RDR2, before treating this multi-level list using
flat() flattens the list to one level, allowing us to filter out only the values which are durations, which we then sum to get the total playing time.
Ay, holroy it’s you again, you had previously helped me with “Query for total time spent studying across all the subjects on a particular day”. Your answer taught me about the FLATTEN data command, thanks for that.
Your code works perfectly, you are really darn good at this, man… How much would you earn as a programmer…
Seems like this time I’ll be looking into and learning about
Your efforts will always be appreciated. I hope to learn new things from you in the future as well.
All in all, I have played RDR2 for 2 day 13 hours 45 minutes in the last two months… I’ll go touch some grass now.
That calculates out to about 5% of your total time during those two months (more if you subtract sleeping time). Good on you for tracking that information and using it to refine your use of time. (Remember, it’s the literally the most non-renewable resource you have. We all get one tank of the stuff, and although it drains away almost imperceptibly at times, once it’s gone, it’s gone.)
Well, it’s been two years since I begin trying to make something out of this mess of a life. Started by simply reading “Atomic Habits”, started waking up at 6, and studying more…
Let’s see what happens…
Starting simple is how many great journeys begin, so it sounds like you’re following in the right footsteps. As someone once said, “The best time to plant a tree is 20 years ago; the second best time is today.” The important thing is that your tree is planted, and it sounds like you’re already starting to benefit from its fruit and shade.
Keep up the great work, and feel free to check in from time to time to share how it’s going if you like!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.