I use Drafts to write my lesson plans, no surprise, but I love it! I made a video about how I use it here:
Not one to leave well enough alone, I am hoping to use a template tag to pre-load an answer to one of the prompts. I want to use the date tag, but I want it to give me the date for tomorrow (example in the screenshot)
The template tags in and of themselves do not support date math, it requires scripting. If you put the following in a script step at the beginning your your action, it will define a new [[tomorrow]] template tag you can use to insert that date in later steps:
// get tomorrow's date
let tomorrow = Date.today().addDays(1);
// convert it to a formatted date string
let s = strftime(tomorrow, "%m-%d-%Y");
// create the template tag
draft.setTemplateTag("tomorrow", s);
// now use [[tomorrow]] in your prompt step
I’m trying to modify Greg’s code to output today and yesterday’s date as YYYY-MM-DD
Here’s what I tried:
// get tomorrow's date
let tomorrow = Date.today().addDays(1);
// convert it to a formatted date string
let s = strftime(tomorrow, "%Y-%M-%D");
// create the template tag
draft.setTemplateTag("tomorrow", s);
// now use [[tomorrow]] in your prompt step
// get yesterday's date
let yesterday = Date.today().addDays(-1);
// convert it to a formatted date string
let y = strftime(yesterday, "%Y-%M-%D");
// create the template tag
draft.setTemplateTag("yesterday", y);
// now use [[yesterday]] in your prompt step
Today works like a champ, but yesterday outputs something like:
2021-00-05/01/21
I don’t know Javascript, just trying to hack what Greg wrote, so I’m guessing it’s something obvious that I just can’t see…