What I’m trying to do
Im trying to use Dataview to build a timesheet to keep track of employee clock in and clockout times. id like this query to
- Only pull from files made in the last week
- Calculate total hours - minus 30 minutes for lunch
- Create individual row per employee, per day
- I’m ok with any kind of formatting that returns a readable result.
- Im using this metadata
- Employee:: John Doe
- Login:: 07:00
- Logout:: 15:30
- Employee:: Jane Smith
- Login:: 06:00
- Logout:: 9:30
- Employee:: John Doe
- Im using this dataview query
TABLE Employee, Login, Logout,
(number(split(Logout, ":")[0]) - number(split(Login, ":")[0])
+ (number(split(Logout, ":")[1]) - number(split(Login, ":")[1])) / 60 - 0.5) AS "Total Hours"
FROM ""
WHERE Employee
FLATTEN Employee AS Employee
FLATTEN Login AS Login
FLATTEN Logout AS Logout
And it is returning this result
File8 | Employee | Login | Logout | Total Hours |
---|---|---|---|---|
2023-10-01 | John Doe | 07:00 | 15:30 | 8 |
2023-10-01 | John Doe | 07:00 | 9:30 | 2 |
2023-10-01 | John Doe | 06:00 | 15:30 | 9 |
2023-10-01 | John Doe | 06:00 | 9:30 | 3 |
2023-10-01 | Jane Smith | 07:00 | 15:30 | 8 |
2023-10-01 | Jane Smith | 07:00 | 9:30 | 2 |
2023-10-01 | Jane Smith | 06:00 | 15:30 | 9 |
2023-10-01 | Jane Smith | 06:00 | 9:30 | 3 |
Things I have tried
Disclaimer: i know very little about dataview, but im trying.
Ive used:
- GROUP BY Employee
- several small changes, none of which worked