### Greeting
Say hello to yourself!
```
## Good <% tp.date.now("dddd") %> Morning Samwise!
```
### Next / Prev Day
You can use `tp.date.now` inside a link to create links to your previous and next daily note. The second argument is an offset.
```
[[<% tp.date.now("YYYY-MM-DD", -1) %>|Yesterday]]|[[<% tp.date.now("YYYY-MM-DD", 1) %>|Tomorrow]]
```
### Get A Random Note
This is a little bit more complicated, but not by much! This command add a link to a random note from your vault.
The previous commands were opened with `<%`. To run javascript inside a templater command we bee the use a `<%*` opening.
```
<%*
```
What is `app`? Open your dev console and type `app` into it. Whoa! We have full access to the Obsidian API inside of Templater. This opens up many more possibilities to those brave enough to explore.
`app.vault.getFiles()` returns an array of all the files in your vault
```
const files = app.vault.getFiles()
```
We're using some basic JavaScript to grab a random element from the array. We're storing the random file to a variable `randomNote`. Once you store a variable in a Template, you can reuse it elsewhere
```
const random = Math.floor(Math.random() * (files.length - 1))
const randomNote = files[random]
```
By closing a command with `-%>` we're telling Templater to not add a blank line where this command was. in the template. Super handy for commands that don't return a value like this one.
```
-%>
```
Finally, we grab the `randomNote` and create a link to it.
```
Today's random note is [[<% randomNote.basename %> ]]
```
### Set a default template for the Daily Note File
If you hit the next link, it won't use your daily notes template. Unless you set that up in the Templater settings!
#### Use Date Basis to set the right date
`tp.date.now` includes a few more arguments beyond the format and offset.
- reference: Instead of basic the date on today, we can base it on any date given as reference.
- reference_format: the format of our reference date.
We can use these to make sure the proper date is returned in any daily note created. Go back to where there is `tp.date.now` above and change them to be: `tp.date.now("YYYY-MM-DD", 0, tp.file.title, "YYYY-MM-DD")` the `0` is your offset so don't forget to use `-1` and `1` for the yesterday/tomorrow links.