如何在时间表中拆分时间以说明午夜后的工作?
How to split hours in a timesheet to account for working after midnight?
我正在使用地理定位自动记录我的工作时间。但是,因为我经常在午夜后工作,所以我需要自动 "split" 每天工作的时间。所需的最终结果只是每天工作的时间,每行 Jan 1st - 2 hours
例如:如果我在 1 月 1 日开始工作,工作时间是晚上 10 点到凌晨 2 点,那么两个小时应该计入 1 月 1 日,另外两个小时计入 1 月 2 日。
以下是自动生成的数据示例,基于我实际进入工作区域的时间。
因此,一种可能的解决方案是水平转换此列表,并添加表示 "if not exited by midnight, then add entries "exited: 23:59" & "entered: 00:00" the next day)
在这种情况下,下一步可能如下所示:
但我不知道如何在 Google 表格中转置(?)数据,或自动生成缺失的字段。或者也许有更好的解决方案?
尝试:
=ARRAYFORMULA(QUERY(IFERROR({DATEVALUE(F2:F), G2:G}),
"select Col1,sum(Col2)
where Col2 is not null
group by Col1
label sum(Col2)''"))
E2:
=ARRAYFORMULA(QUERY({QUERY(
IFERROR(SPLIT(SUBSTITUTE(FILTER(B1:B, A1:A="entered"), " at ", "♦"), "♦")),
"select Col1+Col2 label Col1+Col2''"); IFERROR(
IF(INDEX(SPLIT(SUBSTITUTE(FILTER(B:B, A:A="exited"), " at ", "♦"), "♦"),,1)<>
INDEX(SPLIT(SUBSTITUTE(FILTER(B1:B, A1:A="entered"), " at ", "♦"), "♦"),,1),
INDEX(SPLIT(SUBSTITUTE(FILTER(B1:B, A1:A="entered"), " at ", "♦"), "♦"),,1)+
"23:59:59.999",))}, "where Col1 is not null order by Col1", 0))
F2:
=ARRAYFORMULA(QUERY({TRANSPOSE(QUERY(TRANSPOSE(SPLIT(
SUBSTITUTE(FILTER(B:B, A:A="exited"), " at ", "♦"), "♦")),,99^99))*1; IFERROR(
IF(INDEX(SPLIT(SUBSTITUTE(FILTER(B:B, A:A="exited"), " at ", "♦"), "♦"),,1)<>
INDEX(SPLIT(SUBSTITUTE(FILTER(B:B, A:A="entered"), " at ", "♦"), "♦"),,1),
INDEX(SPLIT(SUBSTITUTE(FILTER(B:B, A:A="entered"), " at ", "♦"), "♦"),,1)
+"23:59:59", ))}, "where Col1 is not null order by Col1", 0))
G2:
=ARRAYFORMULA(IF(F2:F="",,F2:F-E2:E))
我正在使用地理定位自动记录我的工作时间。但是,因为我经常在午夜后工作,所以我需要自动 "split" 每天工作的时间。所需的最终结果只是每天工作的时间,每行 Jan 1st - 2 hours
例如:如果我在 1 月 1 日开始工作,工作时间是晚上 10 点到凌晨 2 点,那么两个小时应该计入 1 月 1 日,另外两个小时计入 1 月 2 日。
以下是自动生成的数据示例,基于我实际进入工作区域的时间。
因此,一种可能的解决方案是水平转换此列表,并添加表示 "if not exited by midnight, then add entries "exited: 23:59" & "entered: 00:00" the next day)
在这种情况下,下一步可能如下所示:
但我不知道如何在 Google 表格中转置(?)数据,或自动生成缺失的字段。或者也许有更好的解决方案?
尝试:
=ARRAYFORMULA(QUERY(IFERROR({DATEVALUE(F2:F), G2:G}),
"select Col1,sum(Col2)
where Col2 is not null
group by Col1
label sum(Col2)''"))
E2:
=ARRAYFORMULA(QUERY({QUERY(
IFERROR(SPLIT(SUBSTITUTE(FILTER(B1:B, A1:A="entered"), " at ", "♦"), "♦")),
"select Col1+Col2 label Col1+Col2''"); IFERROR(
IF(INDEX(SPLIT(SUBSTITUTE(FILTER(B:B, A:A="exited"), " at ", "♦"), "♦"),,1)<>
INDEX(SPLIT(SUBSTITUTE(FILTER(B1:B, A1:A="entered"), " at ", "♦"), "♦"),,1),
INDEX(SPLIT(SUBSTITUTE(FILTER(B1:B, A1:A="entered"), " at ", "♦"), "♦"),,1)+
"23:59:59.999",))}, "where Col1 is not null order by Col1", 0))
F2:
=ARRAYFORMULA(QUERY({TRANSPOSE(QUERY(TRANSPOSE(SPLIT(
SUBSTITUTE(FILTER(B:B, A:A="exited"), " at ", "♦"), "♦")),,99^99))*1; IFERROR(
IF(INDEX(SPLIT(SUBSTITUTE(FILTER(B:B, A:A="exited"), " at ", "♦"), "♦"),,1)<>
INDEX(SPLIT(SUBSTITUTE(FILTER(B:B, A:A="entered"), " at ", "♦"), "♦"),,1),
INDEX(SPLIT(SUBSTITUTE(FILTER(B:B, A:A="entered"), " at ", "♦"), "♦"),,1)
+"23:59:59", ))}, "where Col1 is not null order by Col1", 0))
G2:
=ARRAYFORMULA(IF(F2:F="",,F2:F-E2:E))