# Org-roam-dailies: how to browse through previous days

**URL:** <https://org-roam.discourse.group/t/org-roam-dailies-how-to-browse-through-previous-days/1018>\
**Category:** Requests\
**Created:** [December 2, 2020, 2:05am UTC](https://org-roam.discourse.group/t/org-roam-dailies-how-to-browse-through-previous-days/1018 "2020-12-02T02:05:03Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![cool\_ran](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/cool_ran/32/130_2.png) [@cool\_ran](https://org-roam.discourse.group/u/cool_ran)\
**Post date:** [January 23, 2023, 8:07pm UTC](https://org-roam.discourse.group/t/org-roam-dailies-how-to-browse-through-previous-days/1018/22 "2023-01-23T20:07:17Z")

</div>

Here is how to I browse through previsous days. I use file-per-day scheme.

If you are in a buffer: `2022-12-28.org`, how you’re going to  
switch to day `2022-12-27.org` or to day `2022-12-29.org`? I used  
`org-roam-dailies-goto-date` to do such a switch, but the default selection is  
based on the current date, not the buffer the user is currently visiting.

The following snippet can help you to navigate through yesterday’s or  
tomorrow based on the current daily note.

```
(require 'ts)
(defun wr/org-roam-dailies-capture-current-daily-date-yesterday (&optional goto keys)
  ""
  (interactive "P")
  (if (org-roam-dailies--daily-note-p)
      (let* ((ts-default-format "%Y-%m-%d")
             (current-date-for-this-buffer (buffer-file-name))
             (yesterday-date (ts-format (ts-adjust 'day -1 (ts-parse (file-name-sans-extension
                                                                      (file-name-nondirectory current-date-for-this-buffer)))))))
        (progn
          (org-roam-dailies--capture (time-convert (ts-unix (ts-parse yesterday-date))) t keys)
          (org-content 2)))
    (message "Not in a daily buffer")))

(defun wr/org-roam-dailies-capture-current-daily-date-tomorrow (&optional goto keys)
  ""
  (interactive "P")
  (if (org-roam-dailies--daily-note-p)
      (let* ((ts-default-format "%Y-%m-%d")
             (current-date-for-this-buffer (buffer-file-name))
             (tomorrow-date (ts-format (ts-adjust 'day +1 (ts-parse (file-name-sans-extension
                                                                     (file-name-nondirectory current-date-for-this-buffer)))))))
        (progn
          (org-roam-dailies--capture (time-convert (ts-unix (ts-parse tomorrow-date))) t keys)
          (org-content 2)))
    (message "Not in a daily buffer")))

(defhydra wr/hydra-daily-jump (global-map "C-M-; d")
  "There is no yesterday and tomorrow. Only present exists."
  ("j" wr/org-roam-dailies-capture-current-daily-date-yesterday "yesterday")
  ("k" wr/org-roam-dailies-capture-current-daily-date-tomorrow "tomorrow"))

```

Hope it is useful for someone.

---

<div class="post-metadata">

**Author:** ![panmengguan](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@panmengguan](https://org-roam.discourse.group/u/panmengguan)\
**Post date:** [January 24, 2023, 2:21am UTC](https://org-roam.discourse.group/t/org-roam-dailies-how-to-browse-through-previous-days/1018/23 "2023-01-24T02:21:52Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![panmengguan](https://avatars.discourse-cdn.com/v4/letter/p/5f9b8f/32.png) [@panmengguan](https://org-roam.discourse.group/u/panmengguan)\
**Post date:** [January 24, 2023, 2:29am UTC](https://org-roam.discourse.group/t/org-roam-dailies-how-to-browse-through-previous-days/1018/24 "2023-01-24T02:29:57Z")

</div>

Thanks! I have the same daily-note-taking methodology as yours. The org-roam now has the `org-roam-dailies-goto-previous-note` and `org-roam-dailies-goto-next-note` functions, which provide navigation for day switching. However, the `org-journal` provides maturer integration to Emacs calendar compared to `org-roam-dailies`. Therefore, I borrowed two functions from `org-journal` to jump to daily notes in calendar view, which might be helpful for those who do not want to install the entire `org-journal` package.

```auto
      ;; Modified from newest org-journal resipotory [2023-01-23].
      (defun pmg/journal-read-entry (_arg &optional event)
        "Open journal entry for selected date for viewing."
        (interactive
         (list current-prefix-arg last-nonmenu-event))
        (let* ((formated-date (pmg/calendar-date->journal-date
                               (calendar-cursor-to-date t event)))
               (file-full-name (expand-file-name (format "%s.org" formated-date) org-roam-directory)))
          (if (file-exists-p file-full-name)
              (find-file file-full-name))))

      (defun pmg/journal-show-entry (_arg &optional event)
        "Open journal entry for selected date for viewing."
        (interactive
         (list current-prefix-arg last-nonmenu-event))
        (let* ((formated-date (pmg/calendar-date->journal-date
                               (calendar-cursor-to-date t event)))
               (file-full-name (expand-file-name (format "%s.org" formated-date) org-roam-directory)))
          (if (file-exists-p file-full-name)
              (let ((buf (find-file-noselect file-full-name)))
                (display-buffer buf t)))))

      (defun pmg/calendar-date->journal-date (date)
        "Convert a date as returned from the calendar (MONTH DAY YEAR) to a time."
        (format "%04d-%02d-%02d" (nth 2 date) (nth 0 date) (nth 1 date)))
      
      (define-key calendar-mode-map (kbd "r") 'pmg/journal-read-entry)
      (define-key calendar-mode-map (kbd "v") 'pmg/journal-show-entry)

```

---

<div class="post-metadata">

**Author:** ![FFS](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/ffs/32/1286_2.png) [@FFS](https://org-roam.discourse.group/u/FFS)\
**Post date:** [February 25, 2023, 7:58am UTC](https://org-roam.discourse.group/t/org-roam-dailies-how-to-browse-through-previous-days/1018/25 "2023-02-25T07:58:12Z")

</div>

> [@nobiot](#):
>
> The way I get into Dired is simple. In the note you are in, call `C-x C-f`; stock standard `find-file` and type a dot (“.”) and enter (to open the current directory, not a file).

There is a built-in binding in Dired C-x C-j (dired-jump) from buffer to its dir, very useful and saves some keystrokes.

[Previous page](https://org-roam.discourse.group/t/org-roam-dailies-how-to-browse-through-previous-days/1018.md?page=1)
