简体   繁体   English

Excel日期时间公式

[英]Excel Date-Time Formula

I need to fill in dates corresponding to time. 我需要填写与时间相对应的日期。 I just need something that increments the date when the time changes from 23 to 0. Here is what my sheet looks like: 当时间从23变为0时,我只需要增加日期即可。这是我的工作表的样子:

    5/1/2017    23:00
    5/1/2017    23:00
    5/1/2017    23:00
       ?        0:00
       ?        0:00
       ?        0:00

I've tried these with different formats for the time column: 我在时间列中尝试了不同的格式:

IF(AND(B4=0,B3=23),A3+1,A3)

IF(AND(B4="1/0/1900 12:00:00 AM",B3="1/0/1900 11:00:00 PM"),A3+1,A3)

IF(AND(B4="12:00:00 AM",B3="11:00:00 PM"),A3+1,A3)

Your first formula looks correct but you can see where it's wrong if you type =B3=23 into a cell (it's FALSE ). 您的第一个公式看起来是正确的,但是如果您在单元格中输入=B3=23 (这是FALSE ),则可以看到哪里出了问题。 Instead, try B3=23/24 : =IF(AND(B4=0,B3=23/24),A3+1,A3) . 而是尝试B3=23/24=IF(AND(B4=0,B3=23/24),A3+1,A3)

        A           B
1    5/1/2017   11:00:00 PM
2    XXX        12:00:00 AM

Where XXX is = IF(ABS(B1-23/24)<0.001,IF(ABS(B2-24/24)<0.001,A1+1,A1),A1) 其中XXX = IF(ABS(B1-23/24)<0.001,IF(ABS(B2-24/24)<0.001,A1+1,A1),A1)

what we do here is a nested if statement, basically saying if A and B 我们在这里做的是一个嵌套的if语句,基本上是说A和B

where A is "time in cell above is near 11 pm" 其中A是“上方单元格中的时间接近晚上11点”

and B is "time in cell is near zero" B是“单元格中的时间接近零”

the way date/times work in excel is that the fractional portion corresponds to time after midnight. 日期/时间在Excel中的工作方式是小数部分对应于午夜之后的时间。 So 1/24 ~ .041667 is an hour past midnight, and 23/24 is 11 pm 所以1/24〜.041667是午夜之后的一个小时,而23/24是晚上11点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM