[英]What Excel function and process would I use to calculate time between one column and another (6:55AM/3:00PM)?
I need to determine the best way, in Excel, to use the start time in two columns (6:55/AM) and the end time in two columns (1:00/PM) to make 'if'statements such as: If >= 3:00 before 10:00AM, then 'yes'.我需要确定最好的方法,在 Excel 中,使用两列中的开始时间(6:55/AM)和两列中的结束时间(1:00/PM)来制作“if”语句,例如:如果>= 上午 10:00 之前的 3:00,然后选择“是”。 Can anyone tell me if this is even possible?
谁能告诉我这是否可能? And what would be the best way for me to start?
什么是我开始的最佳方式?
I have pulled the 4 columns (6:55/AM/1:00/PM) into two different columns (6:55AM/1:00PM) and then tried using this formula: =text(x16-y16,"hh:mm")
but I cannot get it to do anything further.我已将 4 列 (6:55/AM/1:00/PM) 拉到两个不同的列 (6:55AM/1:00PM) 中,然后尝试使用以下公式:
=text(x16-y16,"hh:mm")
但我无法让它做任何进一步的事情。 I have searched throughout Stack Overflow and don't see anything that resembles this specific situation.我在整个 Stack Overflow 上进行了搜索,没有看到任何类似于这种特定情况的东西。
I need to be able to create if statements such as If >= 3:00 before 10:00AM, then 'yes'.我需要能够在上午 10:00 之前创建 if >= 3:00 等 if 语句,然后是“是”。 So in the above example, yes would be the response, but if my first columns were to be (7:00/AM) then the response will return no.
所以在上面的例子中,yes 将是响应,但如果我的第一列是 (7:00/AM),那么响应将返回 no。
Assuming your time values are text (else you would get something very different if you concatenated as you show, I suggest, to convert them to "real" times: (and This will work if the value in C1
is a date/real time or text.)假设您的时间值是文本(否则,如果您在显示时将它们连接起来,您会得到非常不同的东西,我建议将它们转换为“真实”时间:(如果
C1
中的值是日期/实时或文本。)
=C1+IF(D1="AM",0,0.5)
This formula will, in effect, turn the value in C1
into a real time, and add 12 hours to it (1/2 of a day) if the value in D1
is not AM
.实际上,此公式会将
C1
中的值转换为实时值,如果D1
中的值不是AM
,则将其添加 12 小时(一天的 1/2)。
NOTE: (provoked by a comment of @K.Dᴀᴠɪs) This formula does no error checking at all, assuming all of your data is how you show in your examples.. If that is necessary, you will need to modify the formula.注意:(由@K.Dᴀᴠɪs 的评论引起)这个公式根本没有错误检查,假设您的所有数据都是您在示例中显示的方式。如果有必要,您将需要修改公式。
Edit To check that something has been entered in C1
, as requested in a comment, just do that.编辑要按照评论中的要求检查是否在
C1
中输入了某些内容,只需执行此操作即可。 eg:例如:
=IF(C1="","",C1+IF(AND(LEN(C1)>0,D1="AM"),0,0.5))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.