DAYS

Calculates the difference between two date values. Returns the number of days between the two days. May return a fraction of a day when the arguments include time parts.

note

此功能是「用于 Office 应用程序的开放文档格式 (OpenDocument)」标准 1.2 版本的一部分。(ISO/IEC 26300:2-2015)


语法

DAYS(Date2; Date1)

Date1」是开始日期,「Date2」是结束日期。如果「Date2」早于「Date1」,则结果会是负数。

note

将日期作为公式一部分输入时,日期分隔符 (斜杠与短横线) 会被理解为算术运算符。因此,按此格式输入的日期无法正确识别为日期,导致错误计算。要保持日期作为公式一部分,请使用 DATE 函数,例如「DATE(1954;7;20)」或将日期放在引号内,使用 ISO 8601 标记法,例如「1954-07-20」。请避免使用受区域影响的日期格式,例如「07/20/54」,在其他区域设置下加载文档,会导致计算错误。


tip

支持 ISO 8601 日期时间格式 (及其分隔符扩展格式) 的无歧义转换。如果出现「#VALUE!」错误,请在「 - LibreOffice Calc - 公式」「详细计算设置」区域的「详细信息...」 按钮,「文本转换为数字」列表框,取消选择「生成 #VALUE! 错误」。


示例

=DAYS(TODAY();"2010-01-01")) returns the number of days from January 1, 2010 until today.

=DAYS("1990-10-10";"1980-10-10")」返回 3652 天。

=DAYS(NOW(); TODAY()) returns a fraction of the current day.

请支持我们!