Help

Find Date Time difference only IF a certain single select field is selected

Topic Labels: Formulas
Solved
Jump to Solution
89 3
cancel
Showing results for 
Search instead for 
Did you mean: 

Surely this is an easy formula, but I just can’t get my brain to bend this way:

I am using Airtable for my timesheet for my employees. I would like to improve upon my existing “Total Hours” formula by showing “Total Hours by task” , and each task is a single select item in another field.

Here’s my “Total Hours” formula currently:

DATETIME_DIFF({Time Out},{Time In},‘minutes’) / 60

Field for the different tasks is aptly named: “Task”

Specific Single Select is “Teaching”

Please help! Thanks!

1 Solution

Accepted Solutions
IF(
  {Task} = "Teaching",
  DATETIME_DIFF({Time Out},{Time In},‘minutes’) / 60
)

Should work, but can’t test it easily; lemme know if it’s buggy

See Solution in Thread

3 Replies 3

I gather you have a fairly fixed set of tasks or projects. With the one example you mentioned (“Teaching”) I’m going to extrapolate and guess a few others: Grading, Office Hours, Class Prep. You’re entering a record for each task with start and end time. And you want to get totals by task.

So why don’t you just group these task records by task and get the summary totals for the Total Hours field?

(Minor side note: Perhaps I misunderstand how you’re using it, but i don’t think I’d call that field ‘Total Hours’. If you have a record for ‘Teaching’ with start time 3pm and end time 4pm, that calculated 1 hour difference is a “total” the way I use the term. It’s something like “Time Spent” (on this one task). “Total” would be what I get when I filter the records (say, for this week) and get the calculated total of all the records for teaching this week.)

IF(
  {Task} = "Teaching",
  DATETIME_DIFF({Time Out},{Time In},‘minutes’) / 60
)

Should work, but can’t test it easily; lemme know if it’s buggy

Perfect! Just what I needed. Thank you!

Labels