
表结构如下:
create table item ( "ID" varchar not null, "unixTime" varchar not null, ); 现在
SELECT TO_TIMESTAMP("unixTime"); 就总是提示
ERROR: function to_timestamp(character varying) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts.
但随手试了几个值都没啥问题,比如:
select to_timestamp('1358121600');
select to_timestamp('969408000');
初步怀疑表里有不同 format 的 timestamp 的值,然后 to_timestamp()不能根据不同的 format 自动智能转换?
有没有大佬可以启发下,看这样的情况怎么解决,急急急~谢谢谢谢
1 hooopo 2020 年 10 月 4 日 via Android SELECT TO_TIMESTAMP(unixTime); |
3 hooopo 2020 年 10 月 4 日 via Android 很简单啊 先用 limit 1 测试下是不是数据问题 数据问题就修数据 |
5 hooopo 2020 年 10 月 4 日 via Android 一个正则就行啊 |
6 MoYi123 2020 年 10 月 4 日 select TO_TIMESTAMP("unixTime"::int) from item; |
8 sagaxu 2020 年 10 月 4 日 via Android 不能查一下手册看看这个函数的定义? |
9 sfqtsh 2020 年 10 月 4 日 via Android \df to_timestamp 你看有 character varying 参数的吗? 显然没有! |
11 sfqtsh 2020 年 10 月 4 日 via Android @nuistzhou 那是 format function 一种,且有两个参数。 to_timestamp ( text, text ) → timestamp with time zone Converts string to time stamp according to the given format. (See also to_timestamp(double precision) in Table 9.32.) to_timestamp('05 Dec 2000', 'DD Mon YYYY') → 2000-12-05 00:00:00-05 |