强制为格式化日期

强制为格式化日期

本文介绍了无法将“2012/11/11"强制为格式化日期(长)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Cassandra cql 的新手(cqlsh 4.1.1、Cassandra 2.0.8.39、CQL 规范 3.1.1、Thrift 协议 19.39.0) - 使用 cql COPY 命令从 CSV 格式的文件到表,我得到以下错误:
错误请求:无法将2012/11/11"强制转换为格式化日期(长).
如何使用 cql 更改列,以便它接受来自我的 CSV 文件的日期?

I am new to Cassandra cql (cqlsh 4.1.1, Cassandra 2.0.8.39, CQL spec 3.1.1, Thrift protocol 19.39.0) - using the cql COPY command to a table from a CSV formatted file and I get the following error:
Bad Request: unable to coerce '2012/11/11' to a formatted date (long).
How do I change a column using cql so that it accepts the date from my CSV file?

推荐答案

正如 Brian 所说,要运行 CQL 查询,需要遵循 CQL 时间戳类型.有时看起来确实很奇怪!几周前我遇到了同样的问题,像这样的日期时间插入:

as Brian said, there are CQL timestamp type to follow to get CQL query running. Sometimes it looks like quite weird indeed ! I've got the same issue few weeks ago with a date time insert like this one :

INSERT INTO my_table (id,lastvisitdate) VALUES (1682221,'2012-03-25 02:26:04');

我收到此错误:错误请求:无法将2012-03-25 02:26:04"强制转换为格式化日期(长)!嗯……太糟糕了,因为日期时间似乎是正确的!

I got this error : Bad Request: unable to coerce '2012-03-25 02:26:04' to a formatted date (long) ! mmmm... so bad as the date time seems to be correct !

经过多次尝试和发疯之前,我刚刚在时间末尾添加了一个 Z,Z 代表祖鲁时间,同时也是 UTC 和 GMT :

After many tries and before going nuts, I've just added a Z at the end of the time, Z stands for Zulu time which is also UTC and GMT :

INSERT INTO my_table (id,lastvisitdate) VALUES (1682221,'2012-03-25 02:26:04Z');

是的!有用 !所以不要忘记日期时间值中的时区,它可能会有所帮助!;-)

Yessss ! It works ! So do not forget the timezone in your date time values, it could be helpful ! ;-)

这篇关于无法将“2012/11/11"强制为格式化日期(长)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 02:17