postgresql - 将 Postgres 文本字段转换为时间戳字段时出现问题忽略格式
问题描述
Postgres 90611
尝试使用以下 SQL 将字符串字段转换(file_original_create_datetime)
为新的时间戳字段(new_original_create_datetime)
时,结果仅包括时间,而不包括日期。
update files
set new_original_create_datetime = to_timestamp(file_original_create_datetime, 'YYYY-MM-DD hh24:mi:ss') ::timestamp without time zone at time zone 'Etc/UTC'
解决方案
在这里工作:
select to_timestamp('2019-02-28 21:15:01', 'YYYY-MM-DD hh24:mi:ss')::timestamp without time zone at time zone 'Etc/UTC';
+------------------------+
| timezone |
|------------------------|
| 2019-02-28 22:15:01+01 |
+------------------------+
如果列的类型new_original_create_datetime
是timestamp
,则 UPDATE
应该可以。
推荐阅读
- angular - 如何从 Observable 设置默认表单值?
- vb.net - 如何在 vb.net 中使用 lambda
- android - Jetpack Compose 中的副作用
- java - 在不同的屏幕尺寸和屏幕方向上正确连接两个 ImageView
- node.js - zsh:找不到命令:理智
- asp.net-core - 如何在 Elasticsearch 排序中使用术语查询?
- java - 使用纯 java 配置和属性文件连接到 MySQL 中的多个数据库
- python - 我怎样才能让我的函数运行得更快?
- java - event_start 总是在android中返回联系人号码
- sql - 当列数不相等而不将每个列定义为 NuLL 时,有没有办法在 Impala SQL 中合并两个表