2votes

How can I calculate minutes to add total hours (or minutes) in a formula to add totals?

Hello. I would like to keep track of my time per project. I have a date field that has a start and end time. I can get the total minutes using:

format(dateBetween(end(prop("Clock-In Clock-out")), start(prop("Clock-In Clock-out")), "hours")) + "hr " + format(dateBetween(end(prop("Clock-In Clock-out")), start(prop("Clock-In Clock-out")), "minutes") % 60) + "min"

However, this gives me x minutes in the column that can not be added as a summary. How can I convert the value to a numeric value (minutes is OK, Hours and Minutes will be better).

Thank you...

MK

2 Answers

0vote

avidnotionuser Points1430

Create another property formula and use function ToNumber(prop()) to convert to a numeric value. The in ( ) is the name of the property you used to calculate the minutes.

However, I would recommend watching this YouTube video to solve this problem: Notion Task Management: Calculate How Much Time To Spend On A Task

0vote

freelancerops Points460

Your formula returns text, and text can't be summed. Keep the value as a number and format it only for display.

  1. Add a Formula property called "Minutes" with: dateBetween(end(prop("Clock-In Clock-out")), start(prop("Clock-In Clock-out")), "minutes")
  2. Don't wrap it in format(). That is what turns it into text. Leave it as a Number.
  3. In the table view, click the footer under the Minutes column, choose Calculate, then Sum. Group the view by Project and each group shows its own total.
  4. For hours, add a formula property called "Hours": round(prop("Minutes") / 60 * 100) / 100. Sum works on it too.
  5. For a readable "1h 20m" display, add a formula property called "Display" using: floor(prop("Minutes") / 60) + "h " + prop("Minutes") % 60 + "m". Use it for display only, not for totals.
  6. To total per project across several entries, create a Projects database, relate the time entries to it, and add a Rollup on Minutes with Calculate set to Sum. Use the same "Display" formula idea on the rollup if you want hours and minutes.

ToNumber() will not work on a string like "1hr 20min", so keep the raw number and format it separately.

If it helps, I made a free starter template with this setup: https://2rds.github.io/freelancer-ops/lite.html?ref=notionanswers

Please log in or register to answer this question.

...

Welcome to Notion Answers, where you can ask questions and receive answers from other members of the community.

Please share to grow the Notion Community!

Connect