I would like to ask that “time” (alone) is added to property types, so that it will be possible to measure “duration”. Currently it is possible to use either the “Date” or “Date and Time” properties, why not time also?
Use-case: I want to add my sleep time (08:00 hours or similar) to my daily notes (and duration of other activities I do throughout a day) for the purpose of counting that, like habits. With the Date & Time that’s not possible.
Proposed solution
Add time as a property type option which can then be used either by obsidian or other plugins to track habits.
Current workaround (optional)
I have scoured the internet for the past few days but I am unable to find any good workaround that would not overcomplicate things drastically.
That’s certainly one way to do it, but I’m not sure if it’s the right way. My ultimate goal is to add these “times” at the end of the month/year, so that I can see how much I did this or that. When it’s text, I could probably find a way to add these numbers as integers, but I don’t know how to add it as time, so that minutes count up to hours, etc. If you know of a way of doing that, please let me know, I am very curious, thanks!
I could create a dataview script to display that for you in a note, or a Python script to scrape that data and display this in a console window.
If we did this in Python, we could generate some pretty graph using matplotlib, with durations separated by activity in a pie chart or a bar graph? (or both?)
In dataview, we would be more limited though we could create a table with rows for each activity with their total durations beside them? That’s something you could include in your daily note, though also in those general overview notes.
Thank you for your suggestion. Adding time as a property type would indeed enhance flexibility for tracking durations and specific times, such as sleep duration or other activities.
I would like to second this request. Much of data I keep track of in daily notes is in duration format (sleep duration, time spent reading, studying, exercising, etc), and so I am unable to put it in the frontmatter properties, since durations are not supported. There are many work-arounds, like @Markimus suggested, which maybe is why this doesn’t seem to be a large issue for people, but I am surprised that such a large category of data is excluded from being kept in properties.
Now that properties have such good support, with their own sidebar, and the promise of more built in data-viewing options to come, I would greatly appreciate being able to have durations in the properties as well.
In the meantime, what’s the use-case that having a specific “time” property would give rather than just text? All I can think of is the only difference would be some sort of time-entry popup, which is fairly painful anyway. Text is quick and easy to write.
Here’s how you can do durations right now:
Which uses an inline Dataview calculation like this:
The duration was `$=moment(dv.current().end, 'HH:mm').diff(moment(dv.current().start, 'HH:mm'), 'minute')` minutes.
For me, (though it might be different for the original poster, since he was asking for “time” in order to measure duration, while I just straight up want duration) the difference is that a duration property is a single data variable with both a number and a “unit”. Dataview accepts durations, and can parse the units of hr, min, day etc properly with integer values in front of them. Some days I read for 10 minutes, others for 5 hours, and it would be most user-friendly for me to have the built-in functioning of Obsidian be able to recognize my data on a property named ReadingTime that I enter as “5hr” and be able to SUM it with “10min” on a different day.
I do use Dataview to sum and track my duration data, but I since cannot use duration fields in frontmatter properties, I have kept duration fields in my notes.
You can also do that too right now using text fields - in fact it’s even easier than times because Dataview automatically parses it into a duration for you:
Today I did stuff for `$=dv.current().read_for.plus(dv.current().exercised_for).as('hours')` hours.
Unless I’m not aware of some built-in SUM feature of Obsidian, you’re still going to need to use Dataview or some other Javascript to sum your fields, in which case you can already do that right now.
@AlanG Thanks so much for your reply! I didn’t realize that Dataview would understand durations entered as text fields in frontmatter properties. That is really helpful for me currently, as I can move all my fields into front matter.
I guess my more hidden concern with Obsidian itself recognizing my data as a duration is the projected (on the roadmap the developers have provided) Dynamic views using data stored in properties. If my durations are “just text”, then I won’t be able to use that function with them when it is available.
I suppose we’ll just have to see how it works when it does roll out.
Assuming the Obsidian team don’t take that into account, someone will whip up a quick script to find/replace all your text durations with whatever the new property type is. It’s a very easy problem to solve