Create a daily note based on an arbitrary date

It would be useful to be able to create a link in a recognised date format - for any time in the future or past - and if the note does not exist, it is created with the current daily note template.

I am using Journal at the moment - but willing to move to any plugin that supports it (hint-hint) :slight_smile:

I notice that the ‘calendar-nav’ include has this functionality - creating tomorrow’s daily note if it doesn’t exist.

Is there any way to trigger a daily note creation if I click on an arbitrary link like ‘2026-01-19’?

For something similar, I use these plugins:

I know this may only be useful to you if you understand a bit of JavaScript, but here’s the template I wrote for Templater:

<%*

    /**
     * - Allows the creation of a daily note by entering a natural language date
     * - Checks if a daily note already exists for that date
     * - Moves note into the right folder
     * - Also supports inclusion by the static Daily Note template, which means
     *   the file has a correct filename and folder already.
     *
     * NOTE: why does this include `_daily`? Well, we could just inline the
     *   content of `_daily` here. It's just that it used to be useful as a
     *   separate built-in Obsidian template. The only problem with the built-in 
     *   functionality is that the created/updated fields were incorrectly interpolated
     *   by Obsidian with the daily note's date (as opposed to the current date) but with
     *   the correct time. And who knows if we'll need that standard template
     *   again.
     */

    let fileMomentDate;

    // If the file is already named properly, then most likely this template is actually 
    // included from a standard Daily Note template and is already in the right folder.
    if (tp.file.title.match(/^\d{4}-\d{2}-\d{2}/)) {
        const format = "YYYY-MM-DD";
        fileMomentDate = new moment(tp.file.title, format);
    } else {
        const TARGET_FOLDER = "Daily";
    
        const nld = this.app.plugins.getPlugin('nldates-obsidian');
    
        let nldate, errorMessage = "", input = undefined;
        while (true) {
            if (input === undefined) {
                input = await tp.system.clipboard();
            } else {
                input = await tp.system.prompt(`${errorMessage}Enter date:`, "", true);
                errorMessage = "(Can't parse that.) ";
            }
            nldate = nld.parseDate(input);
            if (!nldate.date) {
                continue;
            }

            const filename = nldate.formattedString;
            if (await tp.file.exists(filename)) {
                errorMessage = `(Note '${filename}' already exists.) `;
                continue;
            }
    
            await tp.file.move(`${TARGET_FOLDER}/${filename}`);
            break;
        }

        fileMomentDate = nldate.moment;
    }

    let content = await tp.file.include('[[_templates/static/_daily]]');
    content = content.replace(/^((?:created|updated):\s+).*$/gm, `$1'${tp.date.now("YYYY-MM-DD HH:mmZ")}'`);
    content = content.replace(/^(title:\s+).*$/gm, `$1'${fileMomentDate.format("YYYY-MM-DD ddd")}'`);
    tR += content;
%>

and this as the static _daily template:

---
title: '{{date:YYYY-MM-DD ddd}}'
updated: '{{date:YYYY-MM-DD}} {{time:HH:mmZ}}'
created: '{{date:YYYY-MM-DD}} {{time:HH:mmZ}}'
---

# Journal

## #journal/diary 

This lets me create a daily note with arbitrary date. However, it doesn’t let you click on an internal link to a non-existent daily note, with an arbitrary date as text.

Yet another variant on how to do this, which I’m incorporating into my vault right now is to use a combination of Templater and Modal forms. This allows me to select the date I want to create the entry for, and into which of my many journal like structures I want to insert it, and finally whether to use a date format for a daily, monthly or yearly note.

The modal form definition

This should be the one to import into the forms editor of Modal forms:

{
  "title": "Journal date picker",
  "name": "Journal date picker",
  "customClassname": "journal_date_picker",
  "fields": [
    {
      "name": "aDate",
      "label": "The date of the journal",
      "description": "",
      "isRequired": true,
      "input": {
        "type": "date",
        "hidden": false
      }
    },
    {
      "name": "baseFolder",
      "label": "Base folder",
      "description": "Fixed part of folder for journal entry",
      "isRequired": false,
      "input": {
        "type": "select",
        "source": "fixed",
        "options": [
          {
            "value": "journal",
            "label": "journal"
          },
          {
            "value": "workJournal",
            "label": "Work journal"
          }
        ]
      }
    },
    {
      "name": "dateFormat",
      "label": "Choose a date format",
      "description": "Date format including variable folder parts",
      "isRequired": false,
      "input": {
        "type": "select",
        "source": "fixed",
        "options": [
          {
            "value": "YYYY/MM/YYYY-MM-DD",
            "label": "Daily - YYYY/MM/YYYY-MM-DD"
          },
          {
            "value": "[Monthly/]YYYY-MM",
            "label": "Monthly - Monthly/YYYY-MM"
          },
          {
            "value": "[Yearly/]YearYYYY",
            "label": "Yearly - Year/YYYY"
          },
          {
            "value": "custom",
            "label": "custom"
          }
        ]
      }
    },
    {
      "name": "customDateFormat",
      "label": "Custom date format",
      "description": "Use moment.js format, i.e. YYYY-MM-DD",
      "isRequired": false,
      "condition": {
        "dependencyName": "dateFormat",
        "type": "isExactly",
        "value": "custom"
      },
      "input": {
        "type": "text",
        "hidden": false
      }
    }
  ],
  "version": "1"
}
My Templater template

And this is what I use to trigger the template, which will create the file if it doesn’t exist, and in any case return you a link to this file.

<%*
const modalForm = app.plugins.plugins.modalforms.api;
const result = await modalForm.openForm("Pick journal and date", { values: { aDate: tp.date.now("YYYY-MM-DD", 1) }});

let dateFmt = result.data.dateFormat == "custom" 
  ? result.data.customDateFormat 
  : result.data.dateFormat
  
const variablePart = moment(result.data.aDate, "YYYY-MM-DD").format(dateFmt)

const filename = variablePart.includes("/")
  ? variablePart.split("/").slice(-1)
  : variablePart
  
const fullfilepath = result.data.baseFolder + "/" + variablePart + ".md"

if ( !(await tp.file.exists(fullfilepath)) ) {
  
  await tp.file.create_new("", 
    variablePart, 
    false, 
    app.vault.getAbstractFileByPath(result.data.baseFolder))
}

tR += "[[" + filename + "]]"

-%>

Typical input dialog could then look like:

image

1 Like

Thanks, all - but these require a few more steps than I’d consider useful. Maybe this is a question for the Journals plugin creator?

If there was some way to trigger the functionality that already exists when

  • clicking at an empty date in the ‘Journals’ calendar,
  • Clicking in the Journals ‘calendar-nav’ include
    when clicking on
  • a correctly formatted date link AND
  • if the file did not already exist
    I would be a happy user :slight_smile:

If I remember right there are calendar plugins that let you click on arbitrary dates. Done

I use the Calendar plugin for this. Really easy to click on a date in the calendar to create a daily note for that day.

1 Like

Hopefully that works for the OP, but I found it to cumbersome to keep opening the right sidebar to access it in combination with not easy switching to other year/month combination. And personally I also miss the opportunity to choose which of my four journal like folders to use, and which type of entry (daily, weekly, monthly, …) to create.

But I’m also contemplating on how to override the creation of a file in a random location following a given date format. If only I could use the folder formats of Templater unrelated to a folder, but only trigger on names. (Hmmm… I could possibly do that from a user function to detect for type at that the start of any folder template…)