This page explores how you can store time in Notion databases as readable text (hh:mm:ss) while still being able to do calculations with those times or do filtering and sorting. Each example database has a few records with a time, we want to be able to calculate the total amount of time of all records.



1. Storing time in databases

1.1 Storing time as text

In this example the timestamp is written as plain text. The Hours, Minutes and Seconds properties contain a formula to extract the amount from the text and convert it to a number. The Duration property contains a formula to calculate the total amount of seconds for each row, so it can be used for sorting or to do calculations. This is the easiest way but may be prone to errors, in case you make a typo in the Time property. However, you can add an additional property which checks if the text in Time is valid. Here I've done this by removing the ":" from the text, converting that to a number and comparing it to what should be the same number. If the result is not a number the comparison fails and it means the text in the Time field is not valid.

Storing time as text

1.2 Storing time components separately (method 1)

In this example the hours, minutes and seconds are stored in separate properties. The Time property contains a formula to format the hours, minutes and seconds to a timestamp. The Duration property contains a formula to calculate the total amount of seconds for each row, so it can be used for sorting or to do calculations. This is a pretty safe way to store time, however it does not take into account negatives or going over the limit when generating the timestamp string, e.g. minutes or seconds being 60 or higher. You can once again add an additional property which checks if the values in Hours, Minutes & Seconds are valid. This is done by checking if the values are higher or equal to 0 and smaller than 60.

Storing time components 1