These are the formulas you will need to follow along with my Time Tracker Build if you want to add my system to your own Task & Time Tracker.

If you would prefer to just download an even more complete template version of what I demo - you can grab my full Task & Projects Time Tracker here

Ultimate Notion Time Tracker: Tasks & Projects

Many thanks!

Simon

Build Tutorial Steps


To follow this build-along tutorial with or without Notion Ai:

  1. Download my free Essential Task Manager Template here or just work with your own related task & projects databases

    https://www.bettercreating.com/taskmanager

  2. Watch This Video & Follow Along!

    https://youtu.be/V8waHcoqAIU

Time Tracker Formulas


Please note you will need to replace each property reference with your own, unless you have named them identically - i.e. the prop(”Start Time”) elements.

  1. Timesheets Database ‘Duration’ Formula:

    if(empty(prop("Start Time")),
      /* No start time available */
      style("Duration: ", "b") + "Hit Start Work",
      if(empty(prop("End Time")),
        /* Started but not finished - calculate time so far */
        lets(
          /* Calculate elapsed time using now() */
          elapsedSeconds, dateBetween(now(), prop("Start Time"), "seconds"),
          elapsedMinutes, round(elapsedSeconds / 60),
          elapsedHours, floor(elapsedMinutes / 60),
          remainingMinutes, mod(elapsedMinutes, 60),
          /* Format the in-progress time with proper styling */
          style("Duration: ", "b") + 
          if(elapsedSeconds < 60,
            /* Less than a minute elapsed */
            style("0h 0m", "b", "green") + " - " + style("In Progress", "b", "orange"),
            /* Show hours and minutes elapsed so far with green numbers */
            style(format(elapsedHours) + "h " + format(remainingMinutes) + "m", "b", "green") + 
            " - " + style("Task In Progress", "b", "orange")
          )
        ),
        /* Calculate time difference for completed tasks */
        lets(
          timeDiffMinutes, dateBetween(prop("End Time"), prop("Start Time"), "minutes"),
          timeDiffSeconds, dateBetween(prop("End Time"), prop("Start Time"), "seconds"),
          /* Calculate hours and minutes with rounding */
          totalMinutes, round(timeDiffSeconds / 60),
          hours, floor(totalMinutes / 60),
          minutes, mod(totalMinutes, 60),
          /* Format the time tracked with proper styling */
          style("Duration: ", "b") + 
          if(timeDiffSeconds < 60,
            /* Less than 60 seconds - report as 0 */
            style("0h 0m", "b", "green"),
            /* Regular time display - hours and minutes only */
            style(format(hours) + "h " + format(minutes) + "m", "b", "green")
          )
        )
      )
    )
    
  2. The Tasks Database ‘Total Time Tracked’ Formula

    lets(
      /* Get all the minutes from timesheet sessions */
      totalMinutes, prop("Timesheet Sessions")
        .map(current.prop("Duration In Minutes"))
        .sum(),
      /* Check if any session is in progress */
      inProgressSessions, prop("Timesheet Sessions")
        .filter(current.prop("Duration").contains("In Progress"))
        .length() > 0,
      /* Calculate days, hours, minutes */
      days, floor(totalMinutes / 1440),  /* 1440 minutes in a day */
      remainingMinutesAfterDays, totalMinutes % 1440,
      hours, floor(remainingMinutesAfterDays / 60),  /* 60 minutes in an hour */
      minutes, remainingMinutesAfterDays % 60,
      /* Format the time display */
      timeDisplay, "",
      timeDisplay, if(days > 0, format(days) + " day" + (days == 1 ? "" : "s") + " ", timeDisplay),
      timeDisplay, if(hours > 0, format(hours) + " hour" + (hours == 1 ? "" : "s") + " ", timeDisplay),
      timeDisplay, timeDisplay + format(minutes) + " minute" + (minutes == 1 ? "" : "s"),
      /* Create the final output with styling */
      ifs(
        /* If no time tracked but session in progress, just show session in progress */
        totalMinutes == 0 and inProgressSessions, 
          style("Time-Tracking", "b") + ": " + style("Session In Progress", "i", "orange"),
        /* If no time tracked and no session in progress */
        totalMinutes == 0, 
          style("Time-Tracking", "b") + ": No Time Tracked",
        /* If time has been tracked */
        style("Time-Tracking", "b") + ": " + style("Total Time Spent: ") + style(timeDisplay, "b", "green") +
          if(inProgressSessions, " - " + style("Session In Progress", "i", "orange"), "")
      )
    )
    
  3. The Projects Database Report Formula

    /* Create title with bold formatting */
    style("Total Time Tracked On Project: ", "b") + 
    /* Check if any time has been tracked */
    lets(
      /* Get total minutes from related tasks */
      totalMinutes, prop("Current Related Tasks").map(current.prop("Minutes Tracked for Projects")).sum(),
      if(empty(totalMinutes) or totalMinutes == 0,
        /* If no time tracked, show message in orange */
        style("No Time Tracked", "b", "orange"),
        /* If time tracked, calculate and format time units */
        lets(
          days, floor(totalMinutes / 1440),
          remainingMinutes, totalMinutes % 1440,
          hours, floor(remainingMinutes / 60),
          minutes, remainingMinutes % 60,
          /* Format the time string based on available units */
          timeString, 
            (if(days > 0, format(days) + (if(days == 1, " day" , " days")) + " ", "")) +
            (if(hours > 0, format(hours) + (if(hours == 1, " hour" , " hours")) + " ", "")) +
            (if(minutes > 0, format(minutes) + (if(minutes == 1, " minute" , " minutes")), "")),
          /* Format in bold green text */
          style(timeString, "b", "green")
        )
      )
    )