Using variables in QuickAdd

I would like to be able to select some text from a note, and create a new event for the Full Calendar plugin, with the user prompted for the “scheduled” date/time.

It seems like this would be possible using a QuickAdd “capture” action. The idea is that I would like to select some text in a note, trigger the QuickAdd capture which will:

  1. Prompt the user (me!) for a “Scheduled” date and time.
  2. Create a new note in the designated folder with an appropriate filename.
  3. Add the YAML metadata front matter that includes the event title, date, and startTime fields populated from the information the user entered, while the endTime defautls to startTime + 1 hour.

Things I have tried

Based on going through the documentation of QuickAdd etc., I came up with the following “Capture”

  1. File Name: calendar/{{DATE}} - {{VALUE}}
  2. Create file with given template:
---
title: {{VALUE}}
allDay: false
date: {{VDATE:scheduled, YYYY-MM-DD HH:mm}}
startTime: {{VDATE:scheduled}}
endTime: {{VDATE:scheduled + 1hr}}
completed: null
---

The problem is that the second and third fields (startTime and endTime) do not get populated. They should show just the time and not the date.

Even better would be a way to use the user-entered date as the filename date rather than just {{DATE}} which is the creation date.

Does anyone have any advice?

Update: I can pull the information into the fields using VALUE instead of VDATE for the subsequent fields:

---
title: {{VALUE}}
allDay: false
date: {{VDATE:scheduled, YYYY-MM-DD HH:mm}}
startTime: {{VALUE:scheduled}}
endTime: {{VALUE:scheduled}} + 1hr
completed: null
---

The problem now is that the second and third fields (startTime and endTime) show the full date and time:

---
title: test
allDay: false
date: 2023-01-22 17:00
startTime: 2023-01-22 17:00
endTime: 2023-01-22 17:00 + 1hr
completed: null
---

I would like to have it show this:

---
title: Test
allDay: false
date: 2023-01-22
startTime: 17:00
endTime: 18:00
completed: null
---

Ok, I’ve figured out how to do this using Templater:

---
title: {{VALUE}}
allDay: false
scheduled: {{VDATE:Scheduled, YYYY-MM-DDTHH:MM}}
date: <% tp.date.now("YYYY-MM-DD", 0, "{{VALUE:Scheduled}}", "YYYY-MM-DDTHH:MM") %>
startTime: <% tp.date.now("HH:MM", 0, "{{VALUE:Scheduled}}", "YYYY-MM-DDTHH:MM") %>
endTime: <% (Number(tp.date.now("HH", 0, "{{VALUE:Scheduled}}", "YYYY-MM-DDTHH:MM")) + 1).toString() + ":00" %>
completed: null
---

Only thing that is sort of clunky is that the end time will become > 24 if anything is scheduled starting at midnight

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.