Dates and time travel


I am developing a time-tracking app with basic functionalities like start pause and finish. What should be the best way to structure my database? What should be the logic behind the app if I later want to compute the time i.e. add or subtract the time to display the total number of hours for each user? A high-level overview would be great.

Thanks in advance

User (User), Start Time (date), End Time (date), Duration (hours), when they fill in the end time it calculates the duration.

To view total hours for a User search for the thing, constrain to a user, then do :each item's duration:sum

1 Like

Thanks for the response @tylerboodman. What about pausing and then resuming again?

Instead of pausing and resuming, could they be done with that Timeclock (I’m calling it that) and just start a new one?

If you’re looking for some kind of “Take break” button/logic, you could ends the timeclock have it calculate the duration, start a new one with the type “break” (option set), schedule an API workflow for 10 minutes in the future (or whatever the break duration is) have it end that, calculate duration, then start a new “standard” one again.

Then you might need another datatype “Timesheet” that contains all the Timeclocks for the day

Timesheet would have its own User (User), Start Time (date), End Time (date), Duration (hours) fields. But those would be calculated each time a Timeclock is changed so it sums the duration each time, sets the earliest time, sets the latest time, etc. Then that would be what you search for to get your daily overview-per-user.

Then you tap/click on Timesheet and get the day’s breakdown of Timeclocks