[英]How to calculate number of days in Excel
I have a date format like 2020-01-17.I would like to calculate number of days till today date.我有一个像 2020-01-17 这样的日期格式。我想计算到今天为止的天数。 I'm trying it's like
我正在尝试它就像
=today() - B2
However it's not working.但是它不起作用。
I changed the format to 01/17/2020 and did我将格式更改为 01/17/2020 并做了
=today() - B2
The result comes as 3/23/1900.结果是 1900 年 3 月 23 日。
This is wrong and I would like to see in number of days.这是错误的,我想在几天内看到。
very simple Check Out Image enter image description here非常简单 查看图片在此处输入图片描述
I think there are 2 issues that you're seeing here.我认为您在这里看到了两个问题。
The result comes as 3/23/1900.
结果是 1900 年 3 月 23 日。
3/23/1900
is probably because of the format of the cell.3/23/1900
的原因可能是因为单元格的格式。 Change cell format to number and you should see your result as a number.=VALUE(today() - B2)
=VALUE(today() - B2)
I would like to calculate number of days till today date
我想计算到今天为止的天数
=DATEDIF(today(), B2,"D")
=DATEDIF(today(), B2,"D")
Here is the documentation for this DATEDIF function. 这是此 DATEDIF function 的文档。
Note : Below is the warning from Microsoft注意:以下是来自微软的警告
Warning : Excel provides the DATEDIF function in order to support older workbooks from Lotus 1-2-3.警告:Excel 提供了 DATEDIF function 以支持来自 Lotus 1-2-3 的旧工作簿。 The DATEDIF function may calculate incorrect results under certain scenarios.
DATEDIF function 在某些情况下可能会计算出错误的结果。 Please see the known issues section of this article for further details
有关详细信息,请参阅本文的已知问题部分
You can you use the datedif fx link: https://exceljet.net/excel-functions/excel-datedif-function您可以使用 datedif fx 链接: https://exceljet.net/excel-functions/excel-datedif-function
=DATEDIF(B2,TODAY(),"D") =DATEDIF(B2,今天(),"D")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.