postgresql - Postgresql 错误:小时“16”对于 12 小时制无效
问题描述
我8/31/2020-16:29:31 PM
在submitted_date
我的桌子的列。我尝试使用该to_timestamp
函数将其转换为时间戳。
我输入的命令是:
select TO_TIMESTAMP(submitted_date, 'MM/DD/YYYY-HH24:MI:SS PM') from table;
我得到这个错误:
ERROR: hour "16" is invalid for the 12-hour clock
HINT: Use the 24-hour clock, or give an hour between 1 and 12.
我知道这很愚蠢。但是我在这里做错了什么?我没有智慧试图解决这个问题。
解决方案
- Your format string is wrong, should be 'MM/DD/YYYY-HH24:MI:SS'
8/31/2020-16:29:31 PM
is invalid.16:29
is4:29 PM
, right?
select to_timestamp('8/31/2020-16:29:31 PM', 'MM/DD/YYYY-HH24:MI:SS "PM"');
works just fine (with quoted PM in the format string).
推荐阅读
- docker - 是否可以将一个 docker 容器中的网络共享挂载传播给同一主机上的其他容器?
- soap - 是否可以通过 Google 跟踪代码管理器中的自定义 HTML 标记发送 SOAP API 调用
- razor - 如何为 Razor 组件 [参数] 属性分配异步值?
- python - Kivy Filechooser 在滚动屏幕上重叠文本
- php - 多对多查询生成器 laravel
- docker - Docker 容器中的 Apache Guacamole:创建到 guacd 的 WebSocket 隧道失败
- ios - 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“字符串心率不代表有效的 UUID”
- git - git从具有不同路径的2个不相关的repos中合并特定目录到目标目录
- sql - 有没有办法将已聚合为单个列的列分开?
- ios - 后续视图的 NavigationTab 不起作用