简体   繁体   English

添加日期作为范围中的文字

[英]Add in dates as a literal in a range

To add in numbers in an array I can do:要在数组中添加数字,我可以这样做:

={1,2,3}

To add in text in an array I can do:要在数组中添加文本,我可以这样做:

={"a","b","c"}

How would I enter in a date?我将如何输入日期? For example, normally I can type in something like 1/1/07 in a cell and it will recognize it as a date.例如,通常我可以在单元格中输入类似1/1/07的内容,它会将其识别为日期。 How would I enter that in into an array, such as:我将如何将其输入到数组中,例如:

={11/21/86, 11/1/14}

在此处输入图像描述

Use DATE function combined with HSTACK as follow:DATE function 与HSTACK结合使用,如下所示:

=HSTACK(DATE(2022,1,14), DATE(2022,5,20))

the array form {} is only for constants (literals).数组形式{}仅适用于常量(文字)。 If you want the information in date format this is one way of doing it.如果您想要日期格式的信息,这是一种方法。 Another way is to use string literals and then convert it to a date format as follow:另一种方法是使用字符串文字,然后将其转换为日期格式,如下所示:

=DATEVALUE({"2022/1/14","2022/5/20"})

In both cases the date should be in the following range: from January 1, 1900 to December 31, 9999.在这两种情况下,日期应在以下范围内:从 1900 年 1 月 1 日到 9999 年 12 月 31 日。

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

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