Ability to create a template that is a task scheduled for today

Can a template be created, that is a task scheduled for today?


NOW #B Buy soap
  SCHEDULED: <2023-02-25 Sat>

Replacing the date with <% Today %> in a template doesn’t work since that expands to a link to today’s journal page, not a date that the SCHEDULED: can use.

Discord link

Revisiting this thread because this is also something I really wanted.

I wasn’t able to get this working with any standard things, but with the Full House plugin I was able to achieve this like so:

SCHEDULED: <``today`` ``new Date().toLocaleDateString(‘en-US’, {weekday: ‘short’})``>

1 Like

I took a slightly different approach to this problem by reusing code from the custom macros that replace themselves thread.

My use case

  • I wanted a scheduled task to automatically appear on my journal page each day reminding me to take some vitamins.
  • I use Logseq on both mobile and desktop

So I wrote a macro {{schedule-date-today} }that replaces itsself with SCHEDULED: <todays date> when and only when it is evaluated on a journal page. Otherwise it just behaves as a normal macro.


  • I use :default-templates { :journals } to load a template to the daily journal.
  • I use kits to run custom javascript.


 :default-templates { :journals "daily-journal" }
 :macros {
          :schedule-date-today "<div class='kit' data-kit='expandmacro'>||scheduled today||</div>"


- daily journal template
  template:: daily-journal
  template-including-parent:: false
	- TODO {{icon ef63}} Take vitamins

The :schedule-date-today macro directs kits to run the javascript in the code block contained in the first child block of the page expandmacro.


  logseq.kits.setStatic(function expandmacro(div){
      const blockId = div.closest(".ls-block").getAttribute("blockid");
      const block = logseq.api.get_block(blockId);
      const pageId = block.page.id;
      const page = logseq.api.get_page(pageId);
      const pageIsJournal = page['journal?'];
      if (!pageIsJournal) { console.log('is not journal'); return; }
      // This date is in the org-mode SCHEDULED format
      const date = new Date();
      const day = date.getDate().toString().padStart(2, '0');
      const month = (date.getMonth() + 1).toString().padStart(2, '0'); 
      const year = date.getFullYear();
      const dayOfWeek = date.toLocaleString('en-US', { weekday: 'short' }); 
      const formattedDate = `${year}-${month}-${day} ${dayOfWeek}`;
      const content = block.content;
      const macroStart = content.indexOf("{{" + div.closest(".macro").dataset.macroName);
      const macroEnd = content.indexOf("}}", macroStart) + 2;
      logseq.api.update_block(blockId, content.slice(0, macroStart) + `SCHEDULED: <${formattedDate}>` + content.slice(macroEnd));
  // {{schedule-date-today}}
1 Like