Create a timetracker in Notion using buttons
8 May, 2023
In this blog, I will explain how you can create a timesheet in Notion using the new buttons functionality.
Using this time tracker you'll be able to better understand how much time you are investing in each project. This can be used to adjust your workload or create invoices for your clients. With Notion's buttons function, creating a time tracker is easier than ever.
Create timesheet and projects databases
To get started, you will need to create a Timesheet inline database and a Project inline database.
Within the timesheet database, create the following properties:
- Date property called "Start"
- Date property called "End"
- Select property called "Work Type" - this is optional, I use it to record whether the work I'm doing is development work or a meeting.
- Select property called "Timesheet Status" - add the options Current, Paused, Completed
- Person property
- Relation property - relating it to the projects database - make sure Show on Project is turned on
Within the projects database, create the following properties
- Status property called "Status"
Start Button
Now you create a Start button, that adds a record to the timesheet database.
- Add a button and name it Start - add a relevant icon.
- Set the button properties to the following (image below)
- Add page to Timesheet
- Start property to Now - this records the time and date the button is clicked on.
- Timesheet Status to Current
- Person to Person who clicked button
Pausing Time
Create a new full page database called "Paused Time" and add the following properties to the database:
- Date property called "Start"
- Date property called "End"
- Select property called "Paused Status" with the options Calculated and Paused
- Relation property - relating to the timesheet database, make sure you select Show on Timesheet and limit it to one page.
- Formula property called Time Paused - this works out the difference in time between the start and end date.
empty(prop("End")) ? dateBetween(now(), prop("Start"), "minutes") : dateBetween(prop("End"), prop("Start"), "minutes")
Pausing the Time with buttons
Next you will create a template for the timesheet database that contains 3 buttons, a pause button, an unpause button and a finish job button.
To do this go back to the page with the timesheet database on it and click the start button to create a record in the timesheet database. Open this record and click on "create a template".
Create Table Vew
- Give the template a standard name and icon.
- In the body of the record add a table view to the "Paused Time" database.
- Filter the table to show all the records in the paused database that are related to the timesheet record you are viewing - Click on filter and select timesheet, then select the template name (set in step 1). Click "save for everyone"
- Tidy the table - hide the database name and filter
Create Pause Buttons
- Add a button above the table view and name it Pause - add a relevant icon. This button will add a record to the paused time database.
- Add a step and set the button properties to the following (image below)
- Add page to....Paused Time
- Set Timesheet property to this page - this sets the relation between the timesheet and paused time databases
- Set the start property to Now
- Set the Paused Status property to paused
- Add another step and set to edit pages in ... this page (the timesheet record)
- Set the Timesheet status to Paused
- Done
Create Unpause button
- Add another button and name it Unpause - add a relevant icon. This button will add an end time and date to the paused record in the paused database.
- Set the button properties to the following (image below)
- Add a step and set to Edit pages in Paused Time
- Click next to Page to edit and add a filter, set it the Where Paused Status is Paused
- Set the End property to Now
- Set the Paused Status property to Calculated
- Add another step and set to Edit pages in ... This page (this edits the timesheet record you're in)
- Set the Timesheet status to Current
- Done
Create Finish Job Button
This button will add an end date to the timesheet record.
- Add another button and name it Finish Job - add a relevant icon.
- Set the button properties to the following (image below)
- Add a step and set to Edit pages in This Page
- Set the End property to Now
- Set the Timesheet status to Completed
- Done
Complete the template and set as default
- Rearrange the 3 buttons onto a single row and exit out of the template
- On the timesheet database select the drop-down arrow next to the new button and set the default template to the one you've just created.
Calculating Time
Now you need to add some formulas to the timesheet database to calculate the total time spent on each job, minus all the paused time.
Timesheet Database Formulas
- Add a rollup property to the timesheet database called Paused Minutes - Select the Paused time relation - Select the Time Paused property - Select Sum as the calculate option.
- Add a formula property called Total time (minutes). Set the formula to the following:
empty(prop("End")) ? (dateBetween(now(), prop("Start"), "minutes") - prop("Paused Minutes")) : (dateBetween(prop("End"), prop("Start"), "minutes") - prop("Paused Minutes"))
3.Add a formula property called Total Time and add the following formula. This will convert the time in minutes to a more readable hours and minutes display
(prop("Total time (minutes)") / 60 == 0) ? "00:00" : (format(floor(prop("Total time (minutes)") / 60)) + "hr " + format(prop("Total time (minutes)") - floor(prop("Total time (minutes)") / 60) * 60) + "min")
Projects Database formulas
Lastly you need to add some properties to the projects database, that calculate the total time for each project.
- Start by adding a rollup property, linked to the timesheet relation, select the Total time (minutes) property and you want to sum these in the calculation. Name this property Total time (minutes).
- Create a formula property and call it Total Time. Set the formula to the following:
(prop("Total time (minutes)") / 60 == 0) ? "00:00" : (format(floor(prop("Total time (minutes)") / 60)) + "hr " + format(prop("Total time (minutes)") - floor(prop("Total time (minutes)") / 60) * 60) + "min")
And that's it, you have a simple time-tracking tool where you can use buttons to pause the work and calculate the total time spent on each job.