Simple time tracker with Dataview

I wanted to be able to track hours by noting time in my Daily note, typically by the accompanying notes. I came up with two different approaches that I thought I’d share in case it helps anyone with a similar need.


First create a custom callout. This isn’t strictly necessary but it looks nice. I created one called time so I’d create a time entry with notation like the following:

> [!time] 1, Review docs

And I’d add a custom snippet by adding a file (I call mine callouts.css) in the .obsidian/snippets folder of my vault with the following:

.callout[data-callout="time"] {
        --callout-color: 0, 255, 150;
        --callout-icon: lucide-hourglass;

Then create a page that gathers all of the hours. I keep all of my hours in a “Daily” folder.

// ```dataviewjs
dv.header(2, "Time")
const pages = dv.pages('"Daily"')
let rows = []
for (const page of pages) {
	const content = await
	content.split("\n").forEach(function(line, index, arr) {
	    if (index === arr.length - 1 && line === "") { return; }
	    if (line.startsWith("> [!time]")) {
		    const hours = line.substring(10).split(",")
			rows.push([page.file.path.substring(6,16), hours[0], hours[1]])
dv.table(['File', 'Hours', 'Description'], rows)


This second approach is a little easier and doesn’t require dataviewjs. It uses dataview embedded fields so I can place the following notation anywhere:

Hours:: 1
Description: Review docs

I can also place it inside a callout such as the below (which can also take advantage of the custom CSS from above):

Hours:: 1
Description:: Review docs

Then create a page that gathers all of the hours using the dataview:

// ```dataview
FROM "Daily"

Both of these approaches have their own pros and cons, and are both also dependent on reasonably precise notation. This took me an hour or two to figure out as I was learning Obsidian custom snippets and Dataview at the same time, so I’m hoping that this can help save someone a few hours of digging around. That said, I’m quite happy I was able to create something so easy to use and yet reasonably powerful in well under half a day AND learn some cool stuff for future Obsidian projects.

Next step is to restrict the hours so that I’m only looking at specific date ranges.