Google 表格单元格中的 ISO-8601 字符串到日期 [英] ISO-8601 String to Date in Google Sheets cell
问题描述
我的工作表的一列中有一堆 ISO-8601 格式的字符串.如何让谷歌表将它们视为日期,以便我可以对它们进行数学运算(例如,两个单元格之间的分钟差)?我只试过 =Date("2015-05-27T01:15:00.000Z")
但不高兴.必须有一个简单的方法来做到这一点.有什么建议吗?
I have a bunch of ISO-8601 formatted strings in a column of my sheet. How can I get google sheets to treat them as Dates so I can do math on them (difference in minutes between two cells, for example)? I tried just =Date("2015-05-27T01:15:00.000Z")
but no-joy. There has to be an easy way to do this. Any advice?
推荐答案
要获取实际日期值,您可以使用普通数字格式对其进行格式化...
To get an actual Date value which you can format using normal number formatting...
=DATEVALUE(MID(A1,1,10)) + TIMEVALUE(MID(A1,12,8))
例如
A | B | |
---|---|---|
1 | 2016-02-22T05:03:21Z | 2/22/16 5:03:21 AM |
- 假设时间戳采用 UTC
- 忽略毫秒(尽管您可以轻松添加)
DATEVALUE()
函数转换一个格式化的日期字符串转换成一个值,TIMEVALUE()
做同样的事情次.在大多数电子表格中日期&时间由一个数字表示,其中整数部分是自 1900 年 1 月 1 日以来的天数,小数部分是作为一天的一部分的时间.例如,2009 年 6 月 11 日 17:30 大约是 39975.72917.
The DATEVALUE()
function turns a formatted date string into a value, and TIMEVALUE()
does the same for times. In most spreadsheets dates & times are represented by a number where the integer part is days since 1 Jan 1900 and the decimal part is the time as a fraction of the day. For example, 11 June 2009 17:30 is about 39975.72917.
上述公式分别解析日期部分和时间部分,然后将它们相加.
The above formula parses the date part and the time part separately, then adds them together.
这篇关于Google 表格单元格中的 ISO-8601 字符串到日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!