Managing time and date in notes

Processing information by time and date intervals is a very common operation in knowledge management and data analysis.
Conceptually, there are two main approaches:
- Store complete information in a single field and dynamically derive secondary values whenever you need them.
- Store derived data up front so it is immediately available for processing.
Variants of the second approach are common, since the first is only practical when you rely on a single field or property. Both approaches have advantages and trade-offs.
Complete information with dynamically derived data
- Pros:
- Simple to create.
- Minimal storage requirements.
 
- Cons:
- Requires complex formulas and repeated calculations whenever you need derived values.
 
If you choose this approach, the recommended format is:
YYYY-MM-DD[T]HH:mm:ss[Z]ZZ
This format encapsulates full date-time information, including timezone, and allows you to derive any other value from it.
Derived Information and Simpler Processing
- Pros:
- Easier formulas.
- Faster queries and better visualization.
- Common in BI tools, where pre-calculated fields speed up analysis.
 
- Cons:
- More complex to generate initially.
- Slightly more storage required (though negligible in text-based systems like Obsidian).
 
Recommended Minimum Fields
To balance flexibility and usability, include at least:
- Creation time (YYYY-MM-DD[T]HH:mm:ss[Z]ZZ)
- Modification time (same format)
- Date (YYYY-MM-DD)
- Month (MM)
- Year-Month (YYYY-MM)
- Quarter ([Q]Q)
- Year-Quarter (YYYY-[Q]Q)
- Week (ww)
- Day of week (dddd)
- Year-Week (gggg-[W]ww) — accounts for years with 53 weeks
- Year (YYYY)
These fields allow grouping and filtering by multiple time dimensions, supporting both operational and statistical use cases.
Implementation with moment.js and Templater
You can automate field generation in Obsidian templates with code like this:
<%*
   let tt = moment();
-%>
(...)
date: "<% tt.format('YYYY-MM-DD') %>"
month: <% tt.format('MM') %>
monthyear: "<% tt.format('YYYY-MM') %>"
quarter: "<% tt.format('[Q]Q') %>"
quarteryear: "<% tt.format('YYYY-[Q]Q') %>"
week: <% tt.format('ww') %>
weekday: "<% tt.format('dddd') %>"
weekyear: "<% tt.format('gggg-[W]ww') %>"
year: <% tt.format('YYYY') %>
created: <% tt.format('YYYY-MM-DD[T]HH:mm:ss[Z]ZZ') %>
Example Output
date: 2024-05-23
month: 5
monthyear: 2024-05
quarter: Q2
quarteryear: 2024-Q2
week: 21
weekday: Thursday
weekyear: 2024-W21
year: 2024
created: 2024-05-23T18:47:08Z-0600
Best Practice: Consistency
Consistency is key. Place the above snippet in a dedicated template (e.g., Template - Frontmatter - Dates) and include it in other templates with:
<% tp.file.include("[[Template - Frontmatter - Dates]]") %>
This ensures all your notes follow the same structure, making them easier to query, analyze, and maintain over time.