Date & Time Functions

这些电子表格函数用于插入和编辑日期与时间。

要访问此命令...

插入 - 函数 - 类别「日期与时间


note

名称以「_ADD」或「_EXCEL2003」结尾的函数与 Microsoft Excel 2003 中不含后缀的相应函数返回相同结果。使用不带后缀的函数,得到的结果符合国际标准。


LibreOffice internally handles a date/time value as a numerical value. If you assign the numbering format "Number" to a date or time value, it is converted to a number. For example, 2000-01-01 12:00 PM, converts to 36526.5. The value preceding the decimal point corresponds to the date; the value following the decimal point corresponds to the time. If you do not want to see this type of numerical date or time representation, change the number format (date or time) accordingly. To do this, select the cell containing the date or time value, call its context menu and select Format Cells. The Numbers tab page contains the functions for defining the number format.

日期零的日期基准

日期是作为起始日期零的偏移进行计算的。可以将日期零设置为以下内容之一:

日期基准

使用

'1899-12-30'

(默认)

'1900-01-01'

(在以前的 StarCalc 1.0 中使用)

'1904-01-01'

(在 Apple 软件中使用)


选择「 - LibreOffice Calc - 计算」来选择日期基准。

warning

在不同的电子表格之间复制和粘贴包含日期值的单元格时,必须将两个电子表格文档设置为相同的日期基准。如果日期基准不同,显示的日期值将发生变化!


两位数字年份

在「 - LibreOffice - 常规」中, 您可以找到「年份 (两位数字) 」区域。它是用来设置应用于采用双位年份的时间范围。注意: 在此进行的修改会对部分下列函数产生影响。

note

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


tip

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


note

日期时间函数与单元格不使用时区信息。


函数

Date & Time Functions

DATE

DATEDIF

DATEVALUE

DAY

DAYS

DAYS360

DAYSINMONTH

DAYSINYEAR

EASTERSUNDAY

EDATE

EOMONTH

HOUR

ISLEAPYEAR

ISOWEEKNUM

MINUTE

MONTH

MONTHS

NETWORKDAYS

NETWORKDAYS.INTL

NOW

SECOND

TIME

TIMEVALUE

TODAY

WEEKDAY

WEEKNUM

WEEKNUM_EXCEL2003

WEEKNUM_OOO

WEEKS

WEEKSINYEAR

WORKDAY

WORKDAY.INTL

YEAR

YEARFRAC

YEARS

请支持我们!