简体   繁体   English

我将使用什么 Excel function 和过程来计算一列和另一列之间的时间(上午 6 点 55 分/下午 3 点 00 分)?

[英]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.

相关问题 用于查找时间在上午 5:00 和下午 6:00 之间的波高 &lt;3m 的持续时间的功能 - Function for finding duration where wave height <3m where time is between 5:00am and 6:00PM 如何计算有多少小于或大于下午 12:00 的单元格值 - How to count the cell value having time that how many are less than or greater than 12:00pm 在 Excel 中,如何将四个数字转换为 '00:00 AM/PM' 格式? - In Excel, how to convert four numbers into '00:00 AM/PM' format? 如何在Excel中将hhmmAM / PM或hmmAM / PM(无空格)格式化为hh:mm AM / PM时间? - How can I format an hhmmAM/PM OR hmmAM/PM (no space) to time hh:mm AM/PM in excel? 计算处理时间 Excel - Calculate Process Time Excel Application Ontime的问题从11:55 pm到12:00 am-中断循环-VBA - Application Ontime has issue going from 11:55pm to 12:00am - breaks loop - vba Excel用什么方法计算时间和年龄 - Excel what method use to calculate time and age 向 Excel 列追溯添加“am”或“pm” - Retroactivly add "am" or "pm" to an excel column 在 Excel 中,可用于将“上午 9 点到下午 630 点”时间格式转换为军用时间的公式是什么? - What is formula that can be used to convert "9am to 630pm" time format to military time in Excel? 如何根据Excel中另一列的数据计算一列的总和? - How can I calculate the sum of one column based off of the data from another column in Excel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM