# Calculated dates in queries (templates)

**URL:** https://community.silverbullet.md/t/calculated-dates-in-queries-templates/136
**Category:** General
**Created:** [February 11, 2024, 3:40pm UTC](https://community.silverbullet.md/t/calculated-dates-in-queries-templates/136 "2024-02-11T15:40:32Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![Maarrk](https://community.silverbullet.md/user_avatar/community.silverbullet.md/maarrk/32/56_2.png) [@Maarrk](https://community.silverbullet.md/u/Maarrk)
#### Post date: [February 11, 2024, 6:32pm UTC](https://community.silverbullet.md/t/calculated-dates-in-queries-templates/136/3 "2024-02-11T18:32:51Z")

</div>

I wanted to have this to add `previous` and `next` buttons to my weekly notes, and came up with this snippet:

````auto
```space-script
silverbullet.registerFunction("addDays", (date, days) => {
  const plainDate = Temporal.PlainDate.from(date);
  const offsetDate = plainDate.add(Temporal.Duration.from({ days: Number(days) }));
  return offsetDate.toString();
});
```

````

You can use it like this, ~~[unless you want to pass a negative number](https://github.com/silverbulletmd/silverbullet/issues/691)~~:

```auto
{{addDays(today, 7)}}

```

Once I have a few more things I think I would publish with a Library, since I’m already running six SiverBullet instances for family and friends.

---

_[View the full topic](https://community.silverbullet.md/t/calculated-dates-in-queries-templates/136)._
