我只想计算 2023 年 1 月从上午 8:00(08:00)到下午 1:00(13:00)的数据总计。
我使用了以下公式:
=SUMPRODUCT((Sheet1!$A$4:$A$151>=DATE(2023,1,1)+TIME(8,0,0))*(Sheet1!$A$4:$A$151<=DATE(2023,1,1)+TIME(13,0,0))*(Sheet1!$B$4:$B$151))
和:
=SUMIFS(Sheet1!$B$4:$B$151,Sheet1!$A$4:$A$151,">="&DATE(2023,1,1)+TIME(8,0,0),date,"<="&DATE(2023,1,1)+TIME(13,0,0))
它们都给了我错误的结果。
答案1
您应该将日期与时间分开,例如
=SUMPRODUCT(Sheet1!$B$4:$B$151*
(INT(Sheet1!$A$4:$A$151)>=DATE(2023,1,1))*
(INT(Sheet1!$A$4:$A$151)<DATE(2023,2,1))*
(MOD(Sheet1!$A$4:$A$151,1)>=TIME(8,0,0))*
(MOD(Sheet1!$A$4:$A$151,1)<TIME(13,0,0)))